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§
Sourceunsafe fn unchecked_transmute_from(number: Self::Primitive) -> Self
unsafe fn unchecked_transmute_from(number: Self::Primitive) -> Self
Transmutes into an enum from its primitive.
§Safety
number
must represent a valid discriminant ofSelf
.
Provided Methods§
Sourceunsafe 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.
unsafe fn from_unchecked(number: Self::Primitive) -> Self
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 ofSelf
.
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.