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.

Required Associated Types

Underlying representation of a newtype.

Provided Methods

Cast the underlying repr into a wrapper.

Cast wrapper to the underlying repr.

Implementors