bitvec::ptr

Trait Mutability

Source
pub trait Mutability:
    Sized
    + 'static
    + Copy
    + Sealed {
    const SELF: Self;
    const RENDER: &'static str;
    const CONTAINS_MUTABILITY: bool = false;
    const PEANO_NUMBER: usize = 0usize;

    // Provided methods
    fn freeze(self) -> Frozen<Self> { ... }
    fn thaw(_: Frozen<Self>) -> Self { ... }
}
Expand description

Generalized mutability permissions.

This trait enables referent structures to be generic over the write permissions of their referent data. As an example, the standard library defines *const T and *mut T as two duplicate type families, that cannot share any logic at all.

An equivalent library implementation might be Ptr<T, M: Mutability>, where shared logic can be placed in an impl<T, M> Ptr<T, M> block, but unique logic (such as freezing a Mut pointer, or unfreezing a Frozen<Mut>) can be placed in specialized impl<T> Ptr<T, Mut> blocks.

Required Associated Constants§

Source

const SELF: Self

Allow instances to be constructed generically.

Source

const RENDER: &'static str

One of *const or *mut.

Provided Associated Constants§

Source

const CONTAINS_MUTABILITY: bool = false

Marks whether this type contains mutability permissions within it.

This is false for Const and true for Mut. Frozen wrappers atop either of these types inherit their interior marker.

Source

const PEANO_NUMBER: usize = 0usize

Counts the layers of Frozen<> wrapping around a base Const or Mut.

Provided Methods§

Source

fn freeze(self) -> Frozen<Self>

Freeze this type, wrapping it in a const marker that may later be removed to thaw it.

Source

fn thaw(_: Frozen<Self>) -> Self

Thaw a previously-frozen type, removing its Frozen marker and restoring it to Self.

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§

Source§

impl Mutability for Const

Source§

const RENDER: &'static str = "*const"

Source§

const SELF: Const = Self

Source§

impl Mutability for Mut

Source§

const CONTAINS_MUTABILITY: bool = true

Source§

const RENDER: &'static str = "*mut"

Source§

const SELF: Mut = Self

Source§

impl<Inner> Mutability for Frozen<Inner>
where Inner: Mutability,

Source§

const CONTAINS_MUTABILITY: bool = Inner::CONTAINS_MUTABILITY

Source§

const PEANO_NUMBER: usize = _

Source§

const RENDER: &'static str = Inner::RENDER

Source§

const SELF: Frozen<Inner> = _