Trait FromString

Source
pub trait FromString: Sized {
    // Required method
    fn from_string(s: String) -> Result<Self, Error>;
}
Expand description

Parse a value from an owned string

FromString is implemented for all compatible FromStr types. Those are all types with an implementation that fails with an error that can be converted into a Box<dyn Error + Send + Sync>.

This trait cannot be be implemented for custom types because of the blanket implementation. A more ergonomic way to call this is the from_string function.

Required Methods§

Source

fn from_string(s: String) -> Result<Self, Error>

Parses a string `s`` to return a value of this type.

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.

Implementors§

Source§

impl<T> FromString for T
where T: FromStr<Err: Into<Error>> + 'static,