[][src]Struct static_alloc::uninit::UninitView

#[must_use = "This is a pointer-like type that has no effect on its own."]
pub struct UninitView<'a, T: ?Sized>(_);

A non-mutable view on a region used in an Uninit.

Makes it possible to utilize the traversal methods (split*, cast*, ..) without requiring a mutable reference to the original Uninit. It will also never expose mutable pointers or accidentally offer an aliased mutable reference. Prefer this to instead avoiding the borrow of the Uninit and manually managing pointers to the region.

Methods

impl<'_> UninitView<'_, ()>[src]

pub fn split_layout(&mut self, layout: Layout) -> Option<Self>[src]

Split so that the second part fits the layout.

See Uninit::split_layout for more details.

impl<'a> UninitView<'a, ()>[src]

pub fn split_cast<U>(&mut self) -> Option<UninitView<'a, U>>[src]

Split so that the tail is aligned and valid for a U.

pub fn split_slice<U>(&mut self) -> Option<UninitView<'a, [U]>>[src]

Split so that the tail is aligned for a slice [U].

impl<'_, T> UninitView<'_, T>[src]

pub fn invent_for_zst() -> Self[src]

Invent a new uninit allocation for a zero-sized type (ZST).

Panics

This method panics when the type parameter is not a zero sized type.

impl<'a, T> UninitView<'a, T>[src]

pub fn split_at_byte(&mut self, at: usize) -> Option<UninitView<'a, ()>>[src]

Split the uninit view at a byte boundary.

See Uninit::split_at_byte for more details.

pub fn from_maybe_uninit(mem: &'a MaybeUninit<T>) -> Self[src]

Create an view to the inner bytes of a MaybeUninit.

This is hardly useful on its own but since UninitView mirrors the traversal methods of Uninit it can be used to get pointers to already initialized elements in an immutable context.

pub fn cast<U>(self) -> Result<UninitView<'a, U>, Self>[src]

Try to cast to an UninitView for another type.

pub fn cast_slice<U>(self) -> Result<UninitView<'a, [U]>, Self>[src]

Try to cast to an UninitView for a slice type.

pub fn split_to_fit(&mut self) -> UninitView<'a, ()>[src]

Split off the tail that is not required for holding an instance of T.

impl<'a, T> UninitView<'a, [T]>[src]

pub fn empty() -> Self[src]

Creates a pointer to an empty slice.

pub fn as_begin_ptr(&self) -> *const T[src]

Get the pointer to the first element of the slice.

pub fn capacity(&self) -> usize[src]

Calculate the theoretical capacity of a slice in the pointed-to allocation.

pub fn split_at(&mut self, at: usize) -> Option<Self>[src]

Split the slice at an index.

pub fn split_first(&mut self) -> Option<UninitView<'a, T>>[src]

Split the first element from the slice.

pub fn split_last(&mut self) -> Option<UninitView<'a, T>>[src]

Split the last element from the slice.

impl<'a, T: ?Sized> UninitView<'a, T>[src]

pub fn borrow(&self) -> UninitView<T>[src]

Borrow another view of the Uninit region.

pub const fn size(&self) -> usize[src]

Get the byte size of the total allocation.

pub const fn as_ptr(&self) -> *const T[src]

Acquires the underlying *const T pointer.

pub fn as_non_null(&self) -> NonNull<T>[src]

Acquires the underlying pointer as a NonNull.

pub unsafe fn as_ref(&self) -> &T[src]

Dereferences the content.

The resulting lifetime is bound to self so this behaves "as if" it were actually an instance of T that is getting borrowed. If a longer lifetime is needed, use into_ref.

Safety

The caller must ensure that the content has already been initialized.

pub unsafe fn into_ref(self) -> &'a T[src]

Turn this into a reference to the content.

Safety

The caller must ensure that the content has already been initialized.

Trait Implementations

impl<'_, T: ?Sized> Debug for UninitView<'_, T>[src]

impl<'a, T> From<&'a MaybeUninit<T>> for UninitView<'a, T>[src]

impl<'_, T> Default for UninitView<'_, [T]>[src]

Auto Trait Implementations

impl<'a, T: ?Sized> Unpin for UninitView<'a, T> where
    T: Unpin

impl<'a, T> !Sync for UninitView<'a, T>

impl<'a, T> !Send for UninitView<'a, T>

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]