[−][src]Trait parse_arg::ParseArg
Defines an interface for types that can be created by parsing command-line argument.
This trait is similar to FromStr
. See the crate documentation for list of importatn
differences.
Associated Types
Loading content...Required methods
fn parse_arg(arg: &OsStr) -> Result<Self, Self::Error>
Parses the argument.
fn describe_type<W: Write>(writer: W) -> Result
Writes human-readable description of the type to the writer.
The description should be in English composed in such way that appending it to string "The input must be " sounds natural. E.g. if the description is "a number", the resulting phrase will be "The input must be a number".
This way, it can be used as a documentation/hint for the user.
Provided methods
fn parse_owned_arg(arg: OsString) -> Result<Self, Self::Error>
Parses the argument consuming it.
Implementors are encouraged to specialize this method if the resulting implementation is more performant - e.g. if it avoids allocation.
The users are encouraged to use this method instead of parse_arg
if they own the string
and will not need it after call to this function. (Typical when working with
std::env::args_os()
.)
Implementations on Foreign Types
impl ParseArg for String
[src]
Optimized implementation - doesn't allocate in parse_owned_arg
.
type Error = ParseArgError<ParseError>
fn parse_arg(arg: &OsStr) -> Result<Self, Self::Error>
[src]
fn describe_type<W: Write>(writer: W) -> Result
[src]
fn parse_owned_arg(arg: OsString) -> Result<Self, Self::Error>
[src]
impl ParseArg for OsString
[src]
This implementation is a no-op or clone, since OsString
is already OsString
.
type Error = ParseError
fn parse_arg(arg: &OsStr) -> Result<Self, Self::Error>
[src]
fn describe_type<W: Write>(writer: W) -> Result
[src]
fn parse_owned_arg(arg: OsString) -> Result<Self, Self::Error>
[src]
impl ParseArg for PathBuf
[src]
To my knowledge this is a no-op or clone.
type Error = ParseError
fn parse_arg(arg: &OsStr) -> Result<Self, Self::Error>
[src]
fn describe_type<W: Write>(writer: W) -> Result
[src]
fn parse_owned_arg(arg: OsString) -> Result<Self, Self::Error>
[src]
Implementors
impl<T> ParseArg for T where
T: ParseArgFromStr,
<T as FromStr>::Err: Display,
[src]
T: ParseArgFromStr,
<T as FromStr>::Err: Display,