pub trait IntoMut<T: ?Sized>: SmartPointer<T> {
type MutablePointer: SmartPointerMut<T> + Into<Self>;
// Required methods
fn can_make_mut(this: &Self) -> bool;
unsafe fn into_mut_unchecked(this: Self) -> Self::MutablePointer;
unsafe fn get_mut_unchecked(this: &Self) -> &mut T;
// Provided methods
fn into_mut(this: Self) -> Result<Self::MutablePointer, Self> { ... }
fn get_mut(this: &Self) -> Option<&mut T> { ... }
}
Expand description
A SmartPointer
which might grant mutable access, depending on run-time checks.
Required Associated Types§
type MutablePointer: SmartPointerMut<T> + Into<Self>
Required Methods§
Sourcefn can_make_mut(this: &Self) -> bool
fn can_make_mut(this: &Self) -> bool
Check whether converting into a mutable version would succeed.
Sourceunsafe fn into_mut_unchecked(this: Self) -> Self::MutablePointer
unsafe fn into_mut_unchecked(this: Self) -> Self::MutablePointer
Convert into a mutable version without performing runtime checks for upholding any invariants.
Safety: Calling this is safe if and only if can_make_mut
returns true.
Sourceunsafe fn get_mut_unchecked(this: &Self) -> &mut T
unsafe fn get_mut_unchecked(this: &Self) -> &mut T
Obtain a mutable reference to the wrapped value without performing runtime checks for upholding any invariants.
Safety: Calling this is safe if and only if can_make_mut
returns true.
Provided Methods§
Sourcefn into_mut(this: Self) -> Result<Self::MutablePointer, Self>
fn into_mut(this: Self) -> Result<Self::MutablePointer, Self>
Try converting into a mutable version of the pointer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.