pub struct AliasableMut<'a, T: ?Sized> { /* private fields */ }
Expand description
Basic aliasable alternative to &mut
.
Note that this does not circumvent the core aliasing rules of Rust; if you use this to create multiple mutable references to a memory location at the same time, that is still UB. This type just adds a few abilities:
- You may hold any number of
AliasableMut
s and no references to a location. - You may hold any number of
AliasableMut
s and any number of shared references to a location at once. - You may hold any number of
AliasableMut
s and one mutable reference to a location at once.
Implementations§
source§impl<'a, T: ?Sized> AliasableMut<'a, T>
impl<'a, T: ?Sized> AliasableMut<'a, T>
sourcepub fn from_unique(ptr: &'a mut T) -> Self
pub fn from_unique(ptr: &'a mut T) -> Self
Construct an AliasableMut
from an &mut
.
sourcepub fn into_unique(ptr: Self) -> &'a mut T
pub fn into_unique(ptr: Self) -> &'a mut T
Consumes self
and converts it into a non-aliasable &mut
.
sourcepub fn into_unique_pin(pin: Pin<Self>) -> Pin<&'a mut T>
pub fn into_unique_pin(pin: Pin<Self>) -> Pin<&'a mut T>
Convert a pinned AliasableMut
to a pinned &mut
.
sourcepub fn from_unique_pin(pin: Pin<&'a mut T>) -> Pin<Self>
pub fn from_unique_pin(pin: Pin<&'a mut T>) -> Pin<Self>
Convert a pinned &mut
to a pinned AliasableMut
.
Trait Implementations§
source§impl<T: ?Sized> AsMut<T> for AliasableMut<'_, T>
impl<T: ?Sized> AsMut<T> for AliasableMut<'_, T>
source§impl<T: ?Sized> AsRef<T> for AliasableMut<'_, T>
impl<T: ?Sized> AsRef<T> for AliasableMut<'_, T>
source§impl<T> Debug for AliasableMut<'_, T>
impl<T> Debug for AliasableMut<'_, T>
source§impl<T: ?Sized> Deref for AliasableMut<'_, T>
impl<T: ?Sized> Deref for AliasableMut<'_, T>
source§impl<T: ?Sized> DerefMut for AliasableMut<'_, T>
impl<T: ?Sized> DerefMut for AliasableMut<'_, T>
impl<T> Send for AliasableMut<'_, T>
impl<T> Sync for AliasableMut<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for AliasableMut<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for AliasableMut<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Unpin for AliasableMut<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for AliasableMut<'a, T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more