Trait Mutability

Source
pub unsafe trait Mutability:
    Copy
    + Sized
    + Sealed {
    // Required method
    fn mutability() -> MutabilityEnum<Self>;
}
Expand description

This trait is used as a bound on generic mutability parameters.

This trait is implemented by two types, Shared and Mutable, and it is sealed so no other types may implement it.

Not to be confused with MutabilityEnum<M>, which represents a proof about a generic mutability parameter.

Note that while mutability parameters are implemented as type parameters, they represent an entirely different kind of generic parameter. For this reason, the M: Mutability bound should be applied even in struct definitions where bounds are generally discouraged.

Required Methods§

Source

fn mutability() -> MutabilityEnum<Self>

The result of this method lets you match over the mutability values to obtain a proof, which can be used to access features that are only available for one mutability.

Most notably, the GenRef::gen_{into,from}_{mut,shared} methods require a proof of this form.

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.

Implementors§