Skip to main content

UnitEnum

Trait UnitEnum 

Source
pub trait UnitEnum: Copy + Sized {
    // Required methods
    fn to_byte(self) -> u8;
    fn from_byte(byte: u8) -> Option<Self>;
}
Expand description

A fieldless enum with a one-byte representation. Implemented by #[hopper::unit_enum]; hand-written impls must keep from_byte the exact inverse of to_byte on every variant.

Required Methods§

Source

fn to_byte(self) -> u8

The variant’s byte.

Source

fn from_byte(byte: u8) -> Option<Self>

The variant this byte names, if any.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§