Struct RawVecInner

Source
struct RawVecInner<A: Allocator = Global> {
    ptr: Unique<u8>,
    cap: UsizeNoHighBit,
    alloc: A,
}
🔬This is a nightly-only experimental API. (raw_vec_internals)
Expand description

Like a RawVec, but only generic over the allocator, not the type.

As such, all the methods need the layout passed-in as a parameter.

Having this separation reduces the amount of code we need to monomorphize, as most operations don’t need the actual type, just its layout.

Fields§

§ptr: Unique<u8>
🔬This is a nightly-only experimental API. (raw_vec_internals)
§cap: UsizeNoHighBit
🔬This is a nightly-only experimental API. (raw_vec_internals)

Never used for ZSTs; it’s capacity()’s responsibility to return usize::MAX in that case.

§Safety

cap must be in the 0..=isize::MAX range.

§alloc: A
🔬This is a nightly-only experimental API. (raw_vec_internals)

Implementations§

Source§

impl RawVecInner<Global>

Source

fn with_capacity(capacity: usize, elem_layout: Layout) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source§

impl<A: Allocator> RawVecInner<A>

Source

const fn new_in(alloc: A, align: Alignment) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn try_with_capacity_in( capacity: usize, alloc: A, elem_layout: Layout, ) -> Result<Self, TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn with_capacity_zeroed_in( capacity: usize, alloc: A, elem_layout: Layout, ) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn try_allocate_in( capacity: usize, init: AllocInit, alloc: A, elem_layout: Layout, ) -> Result<Self, TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

unsafe fn from_raw_parts_in(ptr: *mut u8, cap: UsizeNoHighBit, alloc: A) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

unsafe fn from_nonnull_in( ptr: NonNull<u8>, cap: UsizeNoHighBit, alloc: A, ) -> Self

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

const fn ptr<T>(&self) -> *mut T

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

const fn non_null<T>(&self) -> NonNull<T>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

const fn capacity(&self, elem_size: usize) -> usize

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn allocator(&self) -> &A

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn current_memory(&self, elem_layout: Layout) -> Option<(NonNull<u8>, Layout)>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn reserve(&mut self, len: usize, additional: usize, elem_layout: Layout)

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn grow_one(&mut self, elem_layout: Layout)

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn try_reserve( &mut self, len: usize, additional: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn reserve_exact(&mut self, len: usize, additional: usize, elem_layout: Layout)

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn try_reserve_exact( &mut self, len: usize, additional: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn shrink_to_fit(&mut self, cap: usize, elem_layout: Layout)

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn needs_to_grow( &self, len: usize, additional: usize, elem_layout: Layout, ) -> bool

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

unsafe fn set_ptr_and_cap(&mut self, ptr: NonNull<[u8]>, cap: usize)

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn grow_amortized( &mut self, len: usize, additional: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn grow_exact( &mut self, len: usize, additional: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

fn shrink( &mut self, cap: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)
Source

unsafe fn shrink_unchecked( &mut self, cap: usize, elem_layout: Layout, ) -> Result<(), TryReserveError>

🔬This is a nightly-only experimental API. (raw_vec_internals)

shrink, but without the capacity check.

This is split out so that shrink can inline the check, since it optimizes out in things like shrink_to_fit, without needing to also inline all this code, as doing that ends up failing the vec-shrink-panic codegen test when shrink_to_fit ends up being too big for LLVM to be willing to inline.

§Safety

cap <= self.capacity()

Source

unsafe fn deallocate(&mut self, elem_layout: Layout)

🔬This is a nightly-only experimental API. (raw_vec_internals)
§Safety

This function deallocates the owned allocation, but does not update ptr or cap to prevent double-free or use-after-free. Essentially, do not do anything with the caller after this function returns. Ideally this function would take self by move, but it cannot because it exists to be called from a Drop impl.

Auto Trait Implementations§

§

impl<A> Freeze for RawVecInner<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for RawVecInner<A>
where A: RefUnwindSafe,

§

impl<A> Send for RawVecInner<A>
where A: Send,

§

impl<A> Sync for RawVecInner<A>
where A: Sync,

§

impl<A> Unpin for RawVecInner<A>
where A: Unpin,

§

impl<A> UnwindSafe for RawVecInner<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)] const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)] const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.