pub unsafe trait StableLayout { }Expand description
Indicates a type with a layout that is stable across Rust compiler versions.
§Safety
The type’s Type Layout must fit one of the following:
- Primitive layout types of 64-bits or less.
- Examples:
i8,u32
- Examples:
- Any zero-sized type (ZST).
- Examples:
()
- Examples:
repr(C)structoruniontypes when all fields are alsoStableLayout.- Examples: Most
libcandwinapitypes.
- Examples: Most
repr(transparent)structoruniontypes when the non-ZST field is alsoStableLayout.- Examples:
Wrapping<T>whereT: StableLayout.
- Examples:
- Any other layout that is guaranteed by Rust.
- Examples:
&Tand&mut TwhereT: Sized.
- Examples:
Specifically there are some things that this type does not attempt to
guarantee. StableLayout types can have:
- Uninitialized bytes, such as padding bytes.
- Invalid bit patterns, such as
boolandchar.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
impl StableLayout for ()
impl StableLayout for NonZeroI8
impl StableLayout for NonZeroI16
impl StableLayout for NonZeroI32
impl StableLayout for NonZeroI64
impl StableLayout for NonZeroIsize
impl StableLayout for NonZeroU8
impl StableLayout for NonZeroU16
impl StableLayout for NonZeroU32
impl StableLayout for NonZeroU64
impl StableLayout for NonZeroUsize
impl StableLayout for Option<NonZeroI8>
impl StableLayout for Option<NonZeroI16>
impl StableLayout for Option<NonZeroI32>
impl StableLayout for Option<NonZeroI64>
impl StableLayout for Option<NonZeroIsize>
impl StableLayout for Option<NonZeroU8>
impl StableLayout for Option<NonZeroU16>
impl StableLayout for Option<NonZeroU32>
impl StableLayout for Option<NonZeroU64>
impl StableLayout for Option<NonZeroUsize>
impl StableLayout for __m128
Available on x86-64 only.
impl StableLayout for __m256
Available on x86-64 only.
impl StableLayout for __m128d
Available on x86-64 only.
impl StableLayout for __m128i
Available on x86-64 only.
impl StableLayout for __m256d
Available on x86-64 only.
impl StableLayout for __m256i
Available on x86-64 only.
impl StableLayout for bool
impl StableLayout for char
impl StableLayout for f32
impl StableLayout for f64
impl StableLayout for i8
impl StableLayout for i16
impl StableLayout for i32
impl StableLayout for i64
impl StableLayout for isize
impl StableLayout for u8
impl StableLayout for u16
impl StableLayout for u32
impl StableLayout for u64
impl StableLayout for usize
impl<T> StableLayout for &Twhere
T: Sized + StableLayout,
impl<T> StableLayout for &mut Twhere
T: Sized + StableLayout,
impl<T> StableLayout for *const Twhere
T: Sized + StableLayout,
impl<T> StableLayout for *mut Twhere
T: Sized + StableLayout,
impl<T> StableLayout for Box<T>where
T: Sized + StableLayout,
Available on crate feature
unsafe_alloc only.impl<T> StableLayout for Cell<T>where
T: StableLayout,
impl<T> StableLayout for ManuallyDrop<T>where
T: StableLayout,
impl<T> StableLayout for NonNull<T>where
T: Sized + StableLayout,
impl<T> StableLayout for Option<&T>where
T: Sized + StableLayout,
impl<T> StableLayout for Option<&mut T>where
T: Sized + StableLayout,
impl<T> StableLayout for Option<Box<T>>where
T: Sized + StableLayout,
Available on crate feature
unsafe_alloc only.impl<T> StableLayout for Option<NonNull<T>>where
T: Sized + StableLayout,
impl<T> StableLayout for PhantomData<T>where
T: StableLayout,
PhantomData is a zero-sized type and so technically it could be defined as
always being StableLayout. However, since PhantomData is semantically
supposed to indicate to the world that you want to be treated like you’re
holding some sort of T, then we will also require that the T be a
StableLayout type.