PrimitiveEnum

Trait PrimitiveEnum 

Source
pub trait PrimitiveEnum
where Self: Sized + Copy,
{ type Primitive: PartialEq + Sized + Copy + Debug; // Required methods fn from_primitive(val: Self::Primitive) -> Option<Self>; fn to_primitive(&self) -> Self::Primitive; fn from_str(s: &str) -> Option<Self>; fn from_str_lower(s: &str) -> Option<Self>; }
Expand description

An enum type that can be packed or unpacked from a simple primitive integer.

Required Associated Types§

Source

type Primitive: PartialEq + Sized + Copy + Debug

The primitve type into which we serialize and deserialize ourselves.

Required Methods§

Source

fn from_primitive(val: Self::Primitive) -> Option<Self>

Convert from a primitive, might fail.

Source

fn to_primitive(&self) -> Self::Primitive

Convert to a primitive value.

Source

fn from_str(s: &str) -> Option<Self>

Convert from a string value representing the variant. Case sensitive.

Source

fn from_str_lower(s: &str) -> Option<Self>

Convert from a string value representing the variant. Lowercase.

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§