[−][src]Struct generic_vec::raw::UninitBuffer
An uninitialized storage. This storage can store values
of any type that has an alignment smaller of equal to T
or A
.
UninitBuffer
has a max capacity of
round_up(size_of::<T>(), align_::<A>()) / size_of::<Element>()
elements.
i.e. UninitBuffer<[i32; 12]>
can store 12 i32
s, but
UninitBuffer<[i32; 1], u64>
can store 2 i32
s. Because u64 is aligned to 8 bytes, so
round_up(4 bytes, 8 bytes) / 4 bytes == 2`
You can query the capacity with UninitBuffer::capacity
assert_eq!(UninitBuffer::<[i32; 12]>::capacity::<i32>(), 12); assert_eq!(UninitBuffer::<[i32; 1], u64>::capacity::<i32>(), 2); assert_eq!(UninitBuffer::<[i32; 1]>::capacity::<u64>(), 0);
In memory representation
This type is represented in memory as
#[repr(C)] struct AlignedBuffer<T, A> { align: [A; 0], value: T, }
The size of the buffer is determined by type paramter T
, and
the alignment is the maximum alignment of T
and A
. This means
that A
should be used to ensure a certain alignment.
Implementations
impl<T, A> UninitBuffer<T, A>
[src]
pub const fn capacity<U>() -> usize
[src]
Get the capacity of this buffer for a given element type
pub const fn uninit() -> Self
[src]
Create a new uninitialized array storage
pub const fn new(value: T) -> Self
[src]
Create a new uninitialized array storage with the given value
Trait Implementations
impl<T, A> Clone for UninitBuffer<T, A>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T, A> Default for UninitBuffer<T, A>
[src]
impl<T, A> Send for UninitBuffer<T, A>
[src]
impl<U, T, A> Storage<U> for UninitBuffer<T, A>
[src]
pub const IS_ALIGNED: bool
[src]
pub fn capacity(&self) -> usize
[src]
pub fn as_ptr(&self) -> *const U
[src]
pub fn as_mut_ptr(&mut self) -> *mut U
[src]
pub fn reserve(&mut self, new_capacity: usize)
[src]
pub fn try_reserve(&mut self, capacity: usize) -> bool
[src]
impl<U, T, A> StorageWithCapacity<U> for UninitBuffer<T, A>
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
impl<T, A> Sync for UninitBuffer<T, A>
[src]
Auto Trait Implementations
impl<T, A> RefUnwindSafe for UninitBuffer<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Unpin for UninitBuffer<T, A> where
A: Unpin,
T: Unpin,
A: Unpin,
T: Unpin,
impl<T, A> UnwindSafe for UninitBuffer<T, A> where
A: UnwindSafe,
T: UnwindSafe,
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,