Derive Macro bytemuck::TransparentWrapper [−][src]
#[derive(TransparentWrapper)] { // Attributes available to this derive: #[transparent] }
Expand description
Derive the TransparentWrapper
trait for a struct
The macro ensures that the struct follows all the the safety requirements
for the TransparentWrapper
trait.
The following constraints need to be satisfied for the macro to succeed
- The struct must be
#[repr(transparent)]
- The struct must contain the
Wrapped
type
If the struct only contains a single field, the Wrapped
type will
automatically be determined if there is more then one field in the struct,
you need to specify the Wrapped
type using #[transparent(T)]
Example
#[derive(Copy, Clone, TransparentWrapper)] #[repr(transparent)] #[transparent(u16)] struct Test<T> { inner: u16, extra: PhantomData<T>, }