Trait ToStr

Source
pub trait ToStr {
    // Required method
    fn to_str(&self) -> &'static str;
}
Expand description

A trait for converting a program’s specific error type to a &str.

Can be used with ProgramError::to_str::<E>() to get an error string belonging to a specific program’s error if the variant is ProgramError::Custom(...), or generic strings from the contained ProgramError for all other variants.

The ProgramError::to_str::<E>() function also requires implementing TryFrom<u32> on an error type, which can be done easily using num_enum::TryFromPrimitive.

Required Methods§

Source

fn to_str(&self) -> &'static str

Implementors§