1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*! Tracking mutability through the trait system. This module enables the pointer structure system to enforce !*/ /// A marker trait for distinguishing `*const` vs `*mut` when working with /// structs, rather than raw pointers. pub trait Mutability: 'static + seal::Sealed {} /// An immutable pointer. #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Const; impl Mutability for Const { } impl seal::Sealed for Const { } /// A mutable pointer. Contexts with a `Mutable` may lower to `Immutable`, then /// re-raise to `Mutable`; contexts with `Immutable` may not raise to `Mutable` /// on their own. #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Mut; impl Mutability for Mut { } impl seal::Sealed for Mut { } #[doc(hidden)] mod seal { #[doc(hidden)] pub trait Sealed {} }