Trait rowan::TransparentNewType
source · pub unsafe trait TransparentNewType: Sized {
type Repr;
fn from_repr(repr: &Self::Repr) -> &Self { ... }
fn into_repr(&self) -> &Self::Repr { ... }
}
Expand description
A marker trait for transparent newtypes.
If you declare a struct like
#[repr(transparent)]
struct Wrapper(Inner)
it is safe to add
unsafe impl TransparentNewType for Wrapper { type Repr = Inner; }
Implementing this trait allows one to cast safely between the wrapper and the underlying representation.