pub unsafe trait Immutable { }
Expand description
Types which are free from interior mutability.
T: Immutable
indicates that T
does not permit interior mutation, except
by ownership or an exclusive (&mut
) borrow.
§Implementation
Do not implement this trait yourself! Instead, use
#[derive(Immutable)]
(requires the derive
Cargo feature);
e.g.:
#[derive(Immutable)]
struct MyStruct {
...
}
#[derive(Immutable)]
enum MyEnum {
...
}
#[derive(Immutable)]
union MyUnion {
...
}
This derive performs a sophisticated, compile-time safety analysis to
determine whether a type is Immutable
.
§Safety
Unsafe code outside of this crate must not make any assumptions about T
based on T: Immutable
. We reserve the right to relax the requirements for
Immutable
in the future, and if unsafe code outside of this crate makes
assumptions based on T: Immutable
, future relaxations may cause that code
to become unsound.
Implementations on Foreign Types§
impl Immutable for bool
impl Immutable for char
impl Immutable for f32
impl Immutable for f64
impl Immutable for i8
impl Immutable for i16
impl Immutable for i32
impl Immutable for i64
impl Immutable for i128
impl Immutable for isize
impl Immutable for str
impl Immutable for u8
impl Immutable for u16
impl Immutable for u32
impl Immutable for u64
impl Immutable for u128
impl Immutable for ()
impl Immutable for usize
impl Immutable for __m128
Available on x86-64 and crate feature
simd
only.impl Immutable for __m128d
Available on x86-64 and crate feature
simd
only.impl Immutable for __m128i
Available on x86-64 and crate feature
simd
only.impl Immutable for __m256
Available on x86-64 and crate feature
simd
only.impl Immutable for __m256d
Available on x86-64 and crate feature
simd
only.impl Immutable for __m256i
Available on x86-64 and crate feature
simd
only.