Expand description
§mutable-constant
This crate provides a smart pointer that allows
mutation on immutable values. In most cases, this
will behave like a normal smart pointer like Box
,
but it allows mutation internally when Rust would
otherwise forbid it.
Doing this is an unsafe operation. You will need
to use unsafe
blocks to use this crate effectively.
§Example
use mutable_constant::Mc;
let mc = Mc::new(42);
let mc_ref = mc.as_ref();
assert_eq!(*mc_ref, 42);
unsafe {
*mc.as_defiant_mut() = 43; // This would normally be a compile error
}
assert_eq!(*mc_ref, 43);
Structs§
- Mc
- A smart pointer that allows mutation on immutable values.