pub trait Parse: Sized {
type Error: ParseError;
// Required method
fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>;
// Provided method
fn name() -> Option<impl Display> { ... }
}Expand description
Parsable types
Required Associated Types§
Sourcetype Error: ParseError
type Error: ParseError
Error type
Required Methods§
Sourcefn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>
fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>
Parses this type from input, mutating it in-place.
Provided Methods§
Sourcefn name() -> Option<impl Display>
fn name() -> Option<impl Display>
A name for this type.
This is mostly used in error reporting and should be a lower case name,
with a / an prefixed. Used for example in the following way:
expected {name}, found {other_name}.
If this returns None, no extra error is displayed when parsing the type.
This is useful for containers that usually don’t want to expose themselves
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.