pub trait Arg: Sized {
type Item;
type Error: Debug + Display;
Show 22 methods
// Required methods
fn update_switches<S: Switches>(&self, switches: &mut S);
fn name(&self) -> String;
fn get(self, matches: &Matches) -> Result<Self::Item, Self::Error>;
// Provided methods
fn validate(&self) -> Result<(), Invalid> { ... }
fn parse_specified_ignoring_validation<I>(
self,
program_name: String,
args: I,
) -> ParseResult<Self::Item, Self::Error>
where I: IntoIterator,
I::Item: AsRef<OsStr> { ... }
fn parse_specified<I>(
self,
program_name: String,
args: I,
) -> ParseResult<Self::Item, Self::Error>
where I: IntoIterator,
I::Item: AsRef<OsStr> { ... }
fn parse_env(self) -> ParseResult<Self::Item, Self::Error> { ... }
fn with_help(self, help_flag: Flag) -> WithHelp<Self> { ... }
fn with_help_default(self) -> WithHelp<Self> { ... }
fn option_map<F, T, U>(self, f: F) -> OptionMap<Self, F>
where F: FnOnce(T) -> U { ... }
fn with_default<T>(self, default_value: T) -> WithDefault<Self, T> { ... }
fn with_default_lazy<F>(
self,
default_value_f: F,
) -> WithDefaultLazy<Self, F> { ... }
fn choice<O>(self, other: O) -> Choice<Self, O>
where O: Arg<Item = Self::Item> { ... }
fn both<O>(self, other: O) -> Both<Self, O>
where O: Arg { ... }
fn map<F, U>(self, f: F) -> Map<Self, F>
where F: FnOnce(Self::Item) -> U { ... }
fn required(self) -> Required<Self> { ... }
fn convert_string<F, T, E>(self, f: F) -> ConvertString<Self, F>
where F: FnOnce(&str) -> Result<T, E> { ... }
fn option_convert_string<F, T, E>(
self,
f: F,
) -> OptionConvertString<Self, F>
where F: FnOnce(&str) -> Result<T, E> { ... }
fn vec_convert_string<F, T, E>(self, f: F) -> VecConvertString<Self, F>
where F: FnMut(&str) -> Result<T, E> { ... }
fn vec_singleton(self) -> VecSingleton<Self> { ... }
fn depend<O>(self, other: O) -> Depend<Self, O>
where O: Arg { ... }
fn some_if<T>(self, t: T) -> SomeIf<Self, T> { ... }
}Required Associated Types§
Required Methods§
fn update_switches<S: Switches>(&self, switches: &mut S)
fn name(&self) -> String
fn get(self, matches: &Matches) -> Result<Self::Item, Self::Error>
Provided Methods§
fn validate(&self) -> Result<(), Invalid>
fn parse_specified_ignoring_validation<I>( self, program_name: String, args: I, ) -> ParseResult<Self::Item, Self::Error>
fn parse_specified<I>( self, program_name: String, args: I, ) -> ParseResult<Self::Item, Self::Error>
Sourcefn parse_env(self) -> ParseResult<Self::Item, Self::Error>
fn parse_env(self) -> ParseResult<Self::Item, Self::Error>
Examples found in repository?
More examples
examples/area.rs (line 11)
5fn main() {
6 match opt::<f32>("", "width", "", "")
7 .depend(opt::<f32>("", "height", "", ""))
8 .option_map(|(x, y)| (x, y))
9 .option_map(|(x, y)| x * y)
10 .required()
11 .parse_env()
12 .result
13 {
14 Ok(area) => println!("area: {:?}", area),
15 Err(e) => panic!("{}", e),
16 }
17}fn with_help(self, help_flag: Flag) -> WithHelp<Self>
Sourcefn with_help_default(self) -> WithHelp<Self>
fn with_help_default(self) -> WithHelp<Self>
Sourcefn option_map<F, T, U>(self, f: F) -> OptionMap<Self, F>where
F: FnOnce(T) -> U,
fn option_map<F, T, U>(self, f: F) -> OptionMap<Self, F>where
F: FnOnce(T) -> U,
Examples found in repository?
examples/area.rs (line 8)
5fn main() {
6 match opt::<f32>("", "width", "", "")
7 .depend(opt::<f32>("", "height", "", ""))
8 .option_map(|(x, y)| (x, y))
9 .option_map(|(x, y)| x * y)
10 .required()
11 .parse_env()
12 .result
13 {
14 Ok(area) => println!("area: {:?}", area),
15 Err(e) => panic!("{}", e),
16 }
17}More examples
fn with_default<T>(self, default_value: T) -> WithDefault<Self, T>
fn with_default_lazy<F>(self, default_value_f: F) -> WithDefaultLazy<Self, F>
fn both<O>(self, other: O) -> Both<Self, O>where
O: Arg,
fn map<F, U>(self, f: F) -> Map<Self, F>
Sourcefn required(self) -> Required<Self>
fn required(self) -> Required<Self>
Examples found in repository?
More examples
examples/area.rs (line 10)
5fn main() {
6 match opt::<f32>("", "width", "", "")
7 .depend(opt::<f32>("", "height", "", ""))
8 .option_map(|(x, y)| (x, y))
9 .option_map(|(x, y)| x * y)
10 .required()
11 .parse_env()
12 .result
13 {
14 Ok(area) => println!("area: {:?}", area),
15 Err(e) => panic!("{}", e),
16 }
17}fn convert_string<F, T, E>(self, f: F) -> ConvertString<Self, F>
fn option_convert_string<F, T, E>(self, f: F) -> OptionConvertString<Self, F>
fn vec_convert_string<F, T, E>(self, f: F) -> VecConvertString<Self, F>
Sourcefn vec_singleton(self) -> VecSingleton<Self>
fn vec_singleton(self) -> VecSingleton<Self>
Sourcefn depend<O>(self, other: O) -> Depend<Self, O>where
O: Arg,
fn depend<O>(self, other: O) -> Depend<Self, O>where
O: Arg,
Examples found in repository?
examples/area.rs (line 7)
5fn main() {
6 match opt::<f32>("", "width", "", "")
7 .depend(opt::<f32>("", "height", "", ""))
8 .option_map(|(x, y)| (x, y))
9 .option_map(|(x, y)| x * y)
10 .required()
11 .parse_env()
12 .result
13 {
14 Ok(area) => println!("area: {:?}", area),
15 Err(e) => panic!("{}", e),
16 }
17}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.