ToAddress

Trait ToAddress 

Source
pub trait ToAddress {
    // Provided method
    fn code(&self) -> u8 { ... }
}
Expand description

Trait for converting tagged enums to their numeric representation.

This trait provides a method to extract the numeric value from enums that use #[repr(u8)]. It uses unsafe pointer casting to access the discriminant value directly.

§Safety

This trait must ONLY be used on enums with #[repr(u8)] attribute. Using it on other types will result in undefined behavior.

§Warning

DO NOT use this trait on anything other than #[repr(u8)] enums.

Provided Methods§

Source

fn code(&self) -> u8

Extract the numeric code from a tagged enum.

Returns the discriminant value of the enum as a u8.

§Safety

This method uses unsafe pointer casting to access the enum discriminant. It is safe only when used on #[repr(u8)] enums.

Implementors§