Skip to main content

IntoMut

Trait IntoMut 

Source
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§

Required Methods§

Source

fn can_make_mut(this: &Self) -> bool

Check whether converting into a mutable version would succeed.

Source

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.

Source

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§

Source

fn into_mut(this: Self) -> Result<Self::MutablePointer, Self>

Try converting into a mutable version of the pointer.

Source

fn get_mut(this: &Self) -> Option<&mut T>

Try obtaining a mutable reference to the wrapped value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§