pub trait PrimaryId: Copy + Debug {
// Required method
fn as_str(&self) -> &'static str;
}Expand description
Trait for primary category identifiers
This is the minimal trait needed for error codes. Just implement .as_str().
§Examples
use waddling_errors::PrimaryId;
#[derive(Debug, Clone, Copy)]
enum Primary {
Syntax,
Type,
}
impl PrimaryId for Primary {
fn as_str(&self) -> &'static str {
match self {
Primary::Syntax => "SYNTAX",
Primary::Type => "TYPE",
}
}
}Required Methods§
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.