aliasable

Struct AliasableMut

source
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 AliasableMuts and no references to a location.
  • You may hold any number of AliasableMuts and any number of shared references to a location at once.
  • You may hold any number of AliasableMuts and one mutable reference to a location at once.

Implementations§

source§

impl<'a, T: ?Sized> AliasableMut<'a, T>

source

pub fn from_unique(ptr: &'a mut T) -> Self

Construct an AliasableMut from an &mut.

source

pub fn into_unique(ptr: Self) -> &'a mut T

Consumes self and converts it into a non-aliasable &mut.

source

pub fn into_unique_pin(pin: Pin<Self>) -> Pin<&'a mut T>

Convert a pinned AliasableMut to a pinned &mut.

source

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>

source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T: ?Sized> AsRef<T> for AliasableMut<'_, T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Debug for AliasableMut<'_, T>
where T: Debug + ?Sized,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: ?Sized> Deref for AliasableMut<'_, T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: ?Sized> DerefMut for AliasableMut<'_, T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, T: ?Sized> From<&'a mut T> for AliasableMut<'a, T>

source§

fn from(ptr: &'a mut T) -> Self

Converts to this type from the input type.
source§

impl<T> Send for AliasableMut<'_, T>
where T: Send + ?Sized,

source§

impl<T> Sync for AliasableMut<'_, T>
where T: Sync + ?Sized,

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.