num_enum

Trait UnsafeFromPrimitive

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§