#[repr(C)]pub struct StableLike<T, As> { /* private fields */ }Expand description
Lets you tell stabby that T has the same stable layout as As.
Lying about this link between T and As will cause UB if a #[repr(stabby)] enum transitively contains
a value of this type.
If you want to be safe when using this, use NoNiches with the correct size and alignment for your
type.
Implementations§
Source§impl<T, As: IStable> StableLike<T, As>
impl<T, As: IStable> StableLike<T, As>
Sourcepub const fn new(value: T) -> Self
pub const fn new(value: T) -> Self
Wraps a value in a type that provides information about its layout.
Asserts that T and As have the same size and aligment at compile time,
and relies on the user for the niche information to be correct.
Sourcepub const unsafe fn as_ref_unchecked(&self) -> &T
pub const unsafe fn as_ref_unchecked(&self) -> &T
Returns a reference to the underlying type
§Safety
This is only safe if T is FFI-safe, or if this self was constructed from a value
of T that was instanciated within the same shared object.
Sourcepub const unsafe fn as_mut_unchecked(&mut self) -> &mut T
pub const unsafe fn as_mut_unchecked(&mut self) -> &mut T
§Safety
This is only safe if T is FFI-safe, or if this self was constructed from a value
of T that was instanciated within the same shared object.
Sourcepub unsafe fn into_inner_unchecked(self) -> T
pub unsafe fn into_inner_unchecked(self) -> T
§Safety
This is only safe if T is FFI-safe, or if this self was constructed from a value
of T that was instanciated within the same shared object.
Sourcepub fn into_inner(self) -> Twhere
T: IStable,
pub fn into_inner(self) -> Twhere
T: IStable,
Extracts the inner value from self
Trait Implementations§
Source§impl<T: Clone, As> Clone for StableLike<T, As>
impl<T: Clone, As> Clone for StableLike<T, As>
Source§impl<T: Debug, As> Debug for StableLike<T, As>
impl<T: Debug, As> Debug for StableLike<T, As>
Source§impl<T: Display, As> Display for StableLike<T, As>
impl<T: Display, As> Display for StableLike<T, As>
Source§impl<T, As: IStable> IStable for StableLike<T, As>
impl<T, As: IStable> IStable for StableLike<T, As>
Source§const ID: u64
const ID: u64
crate::report::gen_id, but can be manually set.Source§const REPORT: &'static TypeReport = As::REPORT
const REPORT: &'static TypeReport = As::REPORT
Source§type ForbiddenValues = <As as IStable>::ForbiddenValues
type ForbiddenValues = <As as IStable>::ForbiddenValues
Source§type UnusedBits = <As as IStable>::UnusedBits
type UnusedBits = <As as IStable>::UnusedBits
Source§type HasExactlyOneNiche = <As as IStable>::HasExactlyOneNiche
type HasExactlyOneNiche = <As as IStable>::HasExactlyOneNiche
core::option::Options are stable: Read more