Traits to represent repr
s
If it is important for a generic parameter to have a particular repr
, you can use
the traits in this crate to ensure that it has the needed repr
.
For example, if you have an unsafe
function that requires a specific repr
,
you can use these traits to create a safe wrapper around it.
use Packed;
// Safety: Only safe to call when T has #[repr(packed)]
unsafe
Implementing the traits from this crate is easy using derive macros. There is a derive macro for each included trait.
# use Packed;
#
;
safe_wrapper;
If the appropriate repr
is not specified, the derive macro will refuse to compile.
;