pub struct Mut<'a, T: ?Sized> { /* private fields */ }Expand description
An immovable mutable reference, like &mut T that cannot be relocated.
Implementations
sourceimpl<'a, T: ?Sized> Mut<'a, T>
impl<'a, T: ?Sized> Mut<'a, T>
sourcepub unsafe fn new_unchecked(ptr: *mut T) -> Self
pub unsafe fn new_unchecked(ptr: *mut T) -> Self
Creates a new Mut from an exclusively borrowed pointer.
Safety
ptrmust be non-null, properly aligned, and valid for reads and writes.ptrmust not alias any other accessible references for'a.- The value pointed to by
ptrmust be initialized and immovable.
sourcepub unsafe fn map_unchecked<F, U>(self, f: F) -> Mut<'a, U>where
F: FnOnce(*mut T) -> *mut U,
pub unsafe fn map_unchecked<F, U>(self, f: F) -> Mut<'a, U>where
F: FnOnce(*mut T) -> *mut U,
Constructs a new Mut by mapping the interior pointer.
Safety
- The pointer returned by
fmust be non-null, properly aligned, and valid for reads and writes. - The pointer returned by
fmust not alias any other accessible references for'a. - The value pointed to by the pointer returned by
fmust be initialized and immutable.
sourcepub fn as_non_null(&self) -> NonNull<T>
pub fn as_non_null(&self) -> NonNull<T>
Returns a NonNull to the referenced value.
sourcepub unsafe fn take(self) -> Val<'a, T>where
T: DropRaw,
pub unsafe fn take(self) -> Val<'a, T>where
T: DropRaw,
Assumes ownership of the value in the Mut.
Safety
- The value pointed to by the
Mutmust be valid for dropping. - The caller must ensure that the value pointed to by the
Mutis never accessed in an illegal state. BecauseValmay drop the value, care must be taken to forget theValor replace the value after dropping it.
Trait Implementations
sourceimpl<'a, T: ?Sized> Destructure for Mut<'a, T>
impl<'a, T: ?Sized> Destructure for Mut<'a, T>
type Underlying = T
type Underlying = T
The underlying type that is destructured.
type Destructuring = Ref
type Destructuring = Ref
The type of destructuring to perform.
sourcefn underlying(&mut self) -> *mut Self::Underlying
fn underlying(&mut self) -> *mut Self::Underlying
Returns a mutable pointer to the underlying type.
sourceimpl<T: DisplayRaw + ?Sized> Display for Mut<'_, T>
impl<T: DisplayRaw + ?Sized> Display for Mut<'_, T>
sourceimpl<'a, T, U: 'a> Restructure<U> for Mut<'a, T>
impl<'a, T, U: 'a> Restructure<U> for Mut<'a, T>
type Restructured = Mut<'a, U>
type Restructured = Mut<'a, U>
The restructured version of this type.
sourceunsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
Restructures a pointer to this type into the target type. Read more
impl<T: ?Sized> RestructurablePointer for Mut<'_, T>
impl<T: Unique + ?Sized> Unique for Mut<'_, T>
impl<T: Pinned<R> + ?Sized, R: Region> Within<R> for Mut<'_, T>
Auto Trait Implementations
impl<'a, T: ?Sized> RefUnwindSafe for Mut<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for Mut<'a, T>
impl<'a, T> !Sync for Mut<'a, T>
impl<'a, T: ?Sized> Unpin for Mut<'a, T>
impl<'a, T> !UnwindSafe for Mut<'a, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more