pub trait Parsable: Sized {
// Required method
fn parse_text(text: &str) -> Result<Self>;
// Provided method
fn parse_source<S>(source: S) -> Result<Self>
where S: LoadSource { ... }
}
Expand description
A type that can be parsed from a text &str
; this provides a parse_source
default method for
parsing any LoadSource
value such as &str
or &Path
:
Required Methods§
Sourcefn parse_text(text: &str) -> Result<Self>
fn parse_text(text: &str) -> Result<Self>
Parse this type from a text &str
.
Provided Methods§
Sourcefn parse_source<S>(source: S) -> Result<Self>where
S: LoadSource,
fn parse_source<S>(source: S) -> Result<Self>where
S: LoadSource,
Parse this type from any LoadSource input.
The default implementation loads the source and delegates to Parsable::parse_text.
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.