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)
struct
orunion
types when all fields are alsoStableLayout
.- Examples: Most
libc
andwinapi
types.
- Examples: Most
repr(transparent)
struct
orunion
types when the non-ZST field is alsoStableLayout
.- Examples:
Wrapping<T>
whereT: StableLayout
.
- Examples:
- Any other layout that is guaranteed by Rust.
- Examples:
&T
and&mut T
whereT: 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
bool
andchar
.
Implementations on Foreign Types§
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 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 ()
impl StableLayout for usize
impl StableLayout for __m128
impl StableLayout for __m128d
impl StableLayout for __m128i
impl StableLayout for __m256
impl StableLayout for __m256d
impl StableLayout for __m256i
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<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,
impl<T> StableLayout for Option<NonNull<T>>where
T: Sized + StableLayout,
impl<T> StableLayout for [T; 0]where
T: StableLayout,
impl<T> StableLayout for [T; 1]where
T: StableLayout,
impl<T> StableLayout for [T; 2]where
T: StableLayout,
impl<T> StableLayout for [T; 3]where
T: StableLayout,
impl<T> StableLayout for [T; 4]where
T: StableLayout,
impl<T> StableLayout for [T; 5]where
T: StableLayout,
impl<T> StableLayout for [T; 6]where
T: StableLayout,
impl<T> StableLayout for [T; 7]where
T: StableLayout,
impl<T> StableLayout for [T; 8]where
T: StableLayout,
impl<T> StableLayout for [T; 9]where
T: StableLayout,
impl<T> StableLayout for [T; 10]where
T: StableLayout,
impl<T> StableLayout for [T; 11]where
T: StableLayout,
impl<T> StableLayout for [T; 12]where
T: StableLayout,
impl<T> StableLayout for [T; 13]where
T: StableLayout,
impl<T> StableLayout for [T; 14]where
T: StableLayout,
impl<T> StableLayout for [T; 15]where
T: StableLayout,
impl<T> StableLayout for [T; 16]where
T: StableLayout,
impl<T> StableLayout for [T; 17]where
T: StableLayout,
impl<T> StableLayout for [T; 18]where
T: StableLayout,
impl<T> StableLayout for [T; 19]where
T: StableLayout,
impl<T> StableLayout for [T; 20]where
T: StableLayout,
impl<T> StableLayout for [T; 21]where
T: StableLayout,
impl<T> StableLayout for [T; 22]where
T: StableLayout,
impl<T> StableLayout for [T; 23]where
T: StableLayout,
impl<T> StableLayout for [T; 24]where
T: StableLayout,
impl<T> StableLayout for [T; 25]where
T: StableLayout,
impl<T> StableLayout for [T; 26]where
T: StableLayout,
impl<T> StableLayout for [T; 27]where
T: StableLayout,
impl<T> StableLayout for [T; 28]where
T: StableLayout,
impl<T> StableLayout for [T; 29]where
T: StableLayout,
impl<T> StableLayout for [T; 30]where
T: StableLayout,
impl<T> StableLayout for [T; 31]where
T: StableLayout,
impl<T> StableLayout for [T; 32]where
T: StableLayout,
impl<T> StableLayout for [T; 48]where
T: StableLayout,
impl<T> StableLayout for [T; 64]where
T: StableLayout,
impl<T> StableLayout for [T; 96]where
T: StableLayout,
impl<T> StableLayout for [T; 128]where
T: StableLayout,
impl<T> StableLayout for [T; 256]where
T: StableLayout,
impl<T> StableLayout for [T; 512]where
T: StableLayout,
impl<T> StableLayout for [T; 1024]where
T: StableLayout,
impl<T> StableLayout for [T; 2048]where
T: StableLayout,
impl<T> StableLayout for [T; 4096]where
T: StableLayout,
impl<T> StableLayout for *const Twhere
T: Sized + StableLayout,
impl<T> StableLayout for *mut Twhere
T: Sized + StableLayout,
impl<T> StableLayout for &Twhere
T: Sized + StableLayout,
impl<T> StableLayout for &mut Twhere
T: Sized + StableLayout,
impl<T> StableLayout for Box<T>where
T: Sized + StableLayout,
impl<T> StableLayout for Cell<T>where
T: StableLayout,
impl<T> StableLayout for UnsafeCell<T>where
T: 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.