pub struct ArgExt<A> { /* private fields */ }
Implementations§
Source§impl<A> ArgExt<A>where
A: Arg,
impl<A> ArgExt<A>where
A: Arg,
pub fn result_map<F, U, E>(self, f: F) -> ArgExt<impl Arg<Item = U, Error = E>>
pub fn result_both<B>( self, b: B, ) -> ArgExt<impl Arg<Item = (Result<A::Item, A::Error>, Result<B::Item, B::Error>), Error = Never>>
pub fn both<B>(
self,
b: B,
) -> ArgExt<impl Arg<Item = (A::Item, B::Item), Error = BothError<A::Error, B::Error>>>where
B: Arg,
pub fn try_map<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = U, Error = TryMapError<A::Error, E>>>
pub fn convert<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = U, Error = TryMapError<A::Error, ConvertFailed<A::Item, E>>>>
pub fn with_help(self, flag: Flag) -> ArgExt<impl Arg<Item = HelpOr<A::Item>>>
pub fn rename( self, name: &str, ) -> ArgExt<impl Arg<Item = A::Item, Error = A::Error>>
pub fn valid(self) -> Valid<A>
Source§impl<A, T> ArgExt<A>
impl<A, T> ArgExt<A>
Sourcepub fn depend<B, U>(
self,
b: B,
) -> ArgExt<impl Arg<Item = Option<(T, U)>, Error = DependError<A::Error, B::Error>>>
pub fn depend<B, U>( self, b: B, ) -> ArgExt<impl Arg<Item = Option<(T, U)>, Error = DependError<A::Error, B::Error>>>
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 .just_parse_env_default()
12 {
13 Ok(area) => println!("area: {:?}", area),
14 Err(e) => panic!("{}", e),
15 }
16}
pub fn otherwise<U>(self, b: U) -> ArgExt<impl Arg<Item = Either<T, U::Item>>>where
U: Arg,
pub fn option_try_map<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = Option<U>, Error = TryMapError<A::Error, E>>>
Sourcepub fn option_map<F, U>(
self,
f: F,
) -> ArgExt<impl Arg<Item = Option<U>, Error = A::Error>>where
F: Fn(T) -> U,
pub fn option_map<F, U>(
self,
f: F,
) -> ArgExt<impl Arg<Item = Option<U>, Error = A::Error>>where
F: Fn(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 .just_parse_env_default()
12 {
13 Ok(area) => println!("area: {:?}", area),
14 Err(e) => panic!("{}", e),
15 }
16}
More examples
pub fn either_or_both_any<B, U>( self, b: B, ) -> ArgExt<impl Arg<Item = Option<EitherOrBoth<T, U>>>>
pub fn either_any<B, U>( self, b: B, ) -> ArgExt<impl Arg<Item = Option<Either<T, U>>>>
pub fn with_default(self, t: T) -> ArgExt<impl Arg<Item = T>>where
T: Clone,
Sourcepub fn required(
self,
) -> ArgExt<impl Arg<Item = T, Error = TryMapError<A::Error, MissingRequiredArg>>>
pub fn required( self, ) -> ArgExt<impl Arg<Item = T, Error = TryMapError<A::Error, MissingRequiredArg>>>
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 .just_parse_env_default()
12 {
13 Ok(area) => println!("area: {:?}", area),
14 Err(e) => panic!("{}", e),
15 }
16}
pub fn option_convert<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = Option<U>, Error = TryMapError<A::Error, ConvertFailed<T, E>>>>
Source§impl<A, I> ArgExt<A>where
A: Arg<Item = I>,
I: IntoIterator,
impl<A, I> ArgExt<A>where
A: Arg<Item = I>,
I: IntoIterator,
pub fn into_iter(self) -> ArgExt<impl Arg<Item = I::IntoIter>>
pub fn vec_try_map<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = Vec<U>, Error = TryMapError<A::Error, E>>>
pub fn vec_map<F, U>( self, f: F, ) -> ArgExt<impl Arg<Item = Vec<U>, Error = A::Error>>
pub fn vec_convert<F, U, E>( self, f: F, ) -> ArgExt<impl Arg<Item = Vec<U>, Error = TryMapError<A::Error, ConvertFailed<I::Item, E>>>>
Source§impl<A, I, T, E> ArgExt<A>
impl<A, I, T, E> ArgExt<A>
pub fn vec_ok_or_first_err( self, ) -> ArgExt<impl Arg<Item = Vec<T>, Error = TryMapError<A::Error, E>>>
Trait Implementations§
Source§impl<A> Arg for ArgExt<A>where
A: Arg,
impl<A> Arg for ArgExt<A>where
A: Arg,
type Item = <A as Arg>::Item
type Error = <A as Arg>::Error
fn update_switches<S: Switches>(&self, switches: &mut S)
fn name(&self) -> String
fn get(&self, matches: &Matches) -> Result<Self::Item, Self::Error>
fn parse<I>( &self, args: I, ) -> (Result<Self::Item, TopLevelError<Self::Error>>, Usage)
fn validate(&self) -> Option<Invalid>
fn parse_env( &self, program_name: ProgramName, ) -> (Result<Self::Item, TopLevelError<Self::Error>>, UsageWithProgramName)
fn parse_env_default( &self, ) -> (Result<Self::Item, TopLevelError<Self::Error>>, UsageWithProgramName)
fn just_parse<I>( &self, args: I, ) -> Result<Self::Item, TopLevelError<Self::Error>>
fn just_parse_env( &self, program_name: ProgramName, ) -> Result<Self::Item, TopLevelError<Self::Error>>
fn just_parse_env_default( &self, ) -> Result<Self::Item, TopLevelError<Self::Error>>
Auto Trait Implementations§
impl<A> Freeze for ArgExt<A>where
A: Freeze,
impl<A> RefUnwindSafe for ArgExt<A>where
A: RefUnwindSafe,
impl<A> Send for ArgExt<A>where
A: Send,
impl<A> Sync for ArgExt<A>where
A: Sync,
impl<A> Unpin for ArgExt<A>where
A: Unpin,
impl<A> UnwindSafe for ArgExt<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more