pub trait UnsafeFromPrimitive: Sized {
    type Primitive: Copy + Eq;

    // Required method
    unsafe fn unchecked_transmute_from(number: Self::Primitive) -> Self;

    // Provided method
    unsafe fn from_unchecked(number: Self::Primitive) -> Self { ... }
}

Required Associated Types§

Required Methods§

source

unsafe fn unchecked_transmute_from(number: Self::Primitive) -> Self

Transmutes into an enum from its primitive.

§Safety
  • number must represent a valid discriminant of Self.

Provided Methods§

source

unsafe fn from_unchecked(number: Self::Primitive) -> Self

👎Deprecated since 0.6.0: Prefer to use unchecked_transmute_from, from_unchecked will be removed in a future release.

Transmutes into an enum from its primitive.

§Safety
  • number must represent a valid discriminant of Self.

Object Safety§

This trait is not object safe.

Implementors§