pub trait Parsable: Sized {
type Err;
// Required method
fn parse(s: &mut ParserString) -> Result<Self, Self::Err>;
// Provided method
fn try_parse(s: &mut ParserString) -> Result<Self, Self::Err> { ... }
}
Expand description
Parse an instance of this type, Similar to [FromStr
].
Required Associated Types§
Required Methods§
sourcefn parse(s: &mut ParserString) -> Result<Self, Self::Err>
fn parse(s: &mut ParserString) -> Result<Self, Self::Err>
Run this parser, using a ParserString
.
Provided Methods§
sourcefn try_parse(s: &mut ParserString) -> Result<Self, Self::Err>
fn try_parse(s: &mut ParserString) -> Result<Self, Self::Err>
Run this parser without affecting the string on failure. In other words, the string will be “rewinded” on failure.
Object Safety§
This trait is not object safe.