pub unsafe trait Packable: Copy {
const MAX_BITS: usize = _;
// Required methods
fn pack(self) -> usize;
unsafe fn unpack(value: usize) -> Self;
}Expand description
A type that can be packed into a pointer.
§Safety
This trait is unsafe because it has certain requirements that must be upheld by the implementor:
unpack(pack(x)) == xfor allx.MAX_BITSmust be the maximum number of bits that are returned bypack.packandunpackmust be infallible.
Provided Associated Constants§
Required Methods§
Sourceunsafe fn unpack(value: usize) -> Self
unsafe fn unpack(value: usize) -> Self
Unpacks a value from an integer previously packed by pack.
§Safety
value MUST have been previously returned by pack. Implementors can assume that
this is the case.
Implementors MUST ensure that the returned value is identical to the value that was
passed to pack. In other words, unpack(pack(x)) == x for all x.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.