Argument

Trait Argument 

Source
pub trait Argument: Any {
    // Required methods
    fn parse(s: &str) -> Result<(&str, Self), ParseError>
       where Self: Sized;
    fn type_name() -> &'static str
       where Self: Sized;
}
Expand description

Defines a parser for argument types, as well as providing downcast for them.

Required Methods§

Source

fn parse(s: &str) -> Result<(&str, Self), ParseError>
where Self: Sized,

Parse the given argument.

§Errors

This should return an error if parsing failed.

Source

fn type_name() -> &'static str
where Self: Sized,

A friendly, user-facing type name. This is used, e.g., in the help command. The recommended style for this is lowercase.

Implementations on Foreign Types§

Source§

impl Argument for i32

Source§

fn parse(s: &str) -> Result<(&str, Self), ParseError>
where Self: Sized,

Source§

fn type_name() -> &'static str
where Self: Sized,

Source§

impl Argument for String

Source§

fn parse(s: &str) -> Result<(&str, Self), ParseError>
where Self: Sized,

Source§

fn type_name() -> &'static str
where Self: Sized,

Implementors§