pub trait ArgAccess<'arg>: Sized {
// Required method
fn take(self) -> Option<&'arg Arg>;
}
Expand description
ArgAccess
allows a visitor to decide if a given parameter needs an argument,
based on the identity of the flag or option.
Consider --foo bar
. Is this a pair of parameters (the flag --foo
and the
positional parameter bar
) or a single option --foo bar
that takes an
argument? Similarly, -ab foo
could be -a b
, foo
; or -a
, -b foo
; or
-a
, -b
, foo
. The ArgumentsParser
can’t independently classify a given
argument, so instead, a visitor can request an argument via this trait only for
options that need them and the ArgumentParser
takes care of the parsing logic
of actually determining where that argument comes from.
Required Methods§
Sourcefn take(self) -> Option<&'arg Arg>
fn take(self) -> Option<&'arg Arg>
Get an argument from the parser. This should only be called by options that need it; flags should simply ignore it, to ensure that the next command line argument can correctly be parsed independently.
This returns None
if all of the CLI arguments have been exhausted, or
if there are known to only be positional parameters remaining (because
a raw --
was parsed at some point).
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.