[][src]Trait possibly_uninit::BorrowUninitMut

pub unsafe trait BorrowUninitMut<Borrowed>: BorrowUninit<Borrowed> {
    fn borrow_uninit_mut(&mut self) -> RefMut<Borrowed>;

    unsafe fn assume_init_mut(&mut self) -> &mut Borrowed { ... }
fn init(&mut self, item: Borrowed) -> &mut Borrowed { ... }
fn default_if_needed(&mut self) -> &mut Borrowed
    where
        Borrowed: Default
, { ... }
fn zeroed_if_needed(&mut self) -> &mut Borrowed
    where
        Borrowed: ZeroValid
, { ... } }

Trait allowing mutably borrowing of MaybeUninit<T> values.

It's analogous to core::borrow::Borrow, expect it works with MaybeUninit values.

Required methods

fn borrow_uninit_mut(&mut self) -> RefMut<Borrowed>

Mutably borrows maybe uninitialized value.

This method must return RefMut instead of normal &mut T because of safety reasons described in the documentation of RefMut type.

Loading content...

Provided methods

unsafe fn assume_init_mut(&mut self) -> &mut Borrowed

Converts the reference assuming it's initialized.

Safety

Calling this method on uninitialized value is undefined behavior.

fn init(&mut self, item: Borrowed) -> &mut Borrowed

Initializes the memory location with valid value.

fn default_if_needed(&mut self) -> &mut Borrowed where
    Borrowed: Default

Overwrites the memory with Default::default() if necessary.

This method is noop on &mut Borrowed types. It may be used when interfacing with legacy code which can't work with MaybeUninit<Borrowed>.

fn zeroed_if_needed(&mut self) -> &mut Borrowed where
    Borrowed: ZeroValid

Overwrites the memory with Default::default() if necessary.

This method is noop on &mut Borrowed types. It may be used when interfacing with legacy code which can't work with MaybeUninit<Borrowed>.

Loading content...

Implementations on Foreign Types

impl<T> BorrowUninitMut<T> for MaybeUninit<T>[src]

impl<'_, T> BorrowUninitMut<T> for &'_ mut MaybeUninit<T>[src]

impl<'_, T> BorrowUninitMut<T> for RefMut<'_, T>[src]

impl<'_, T> BorrowUninitMut<T> for RefMut<'_, MaybeUninit<T>>[src]

Loading content...

Implementors

impl<'_, T> BorrowUninitMut<T> for &'_ mut T[src]

impl<'a, T> BorrowUninitMut<T> for possibly_uninit::RefMut<'a, T>[src]

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

Loading content...