pub struct StringInput<I: Iterator<Item = String> = Args> { /* private fields */ }
Expand description
The default input type for argument parsing. This is generic over its
iterator type and can be used with std::env::args
. See
StringInput::new()
for more information.
Getting the current token and token kind is very cheap. Bumping the token is a bit more expensive, since it involves more complicated logic and might re-allocate.
Implementations§
Trait Implementations§
Source§impl<I: Iterator<Item = String>> Input for StringInput<I>
impl<I: Iterator<Item = String>> Input for StringInput<I>
Source§fn current_str_with_leading_dashes(&self) -> Option<&str>
fn current_str_with_leading_dashes(&self) -> Option<&str>
Returns the current token (including the leading dashes) as string
slice, or None if the input is empty.
Source§fn bump_with_leading_dashes(&mut self, len: usize) -> &str
fn bump_with_leading_dashes(&mut self, len: usize) -> &str
Bumps the current token (including leading dashes) by
len
bytes. Read moreSource§fn bump_argument(&mut self) -> Option<&str>
fn bump_argument(&mut self) -> Option<&str>
Bumps the current argument (including leading dashes) completely.
Source§fn set_ignore_dashes(&mut self, ignore: bool)
fn set_ignore_dashes(&mut self, ignore: bool)
Sets the parsing mode. When
true
, all arguments are considered
positional, i.e. leading dashes are ignored.Source§fn ignore_dashes(&self) -> bool
fn ignore_dashes(&self) -> bool
Returns the parsing mode. When
true
, all arguments are considered
positional, i.e. leading dashes are ignored.Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns
true
if the input is empty. This means that all arguments have
been fully parsed.Source§fn is_not_empty(&self) -> bool
fn is_not_empty(&self) -> bool
Returns
true
if the input is not empty. This means that all arguments
have been fully parsed.Source§fn can_parse_value_no_whitespace(&self) -> bool
fn can_parse_value_no_whitespace(&self) -> bool
Returns
true
if a value within the same argument is expected. Or in
other words, if we just consumed a single-dash flag or an equals sign
and there are remaining bytes in the same argument.Source§fn can_parse_dash_argument(&self) -> bool
fn can_parse_dash_argument(&self) -> bool
Returns
true
if the current token can be parsed as a flag or named
argument (e.g. -h
, --help=config
).Source§fn eat_no_dash<'a>(&mut self, token: &'a str) -> Option<&str>
fn eat_no_dash<'a>(&mut self, token: &'a str) -> Option<&str>
Eat the current token if the argument doesn’t start with dashes and
matches
token
exactly.Source§fn eat_one_dash<'a>(&mut self, token: &'a str) -> Option<&str>
fn eat_one_dash<'a>(&mut self, token: &'a str) -> Option<&str>
Eat the current token if the argument starts with a single dash, and the
current token starts with
token
. Read moreSource§fn eat_two_dashes<'a>(&mut self, token: &'a str) -> Option<&str>
fn eat_two_dashes<'a>(&mut self, token: &'a str) -> Option<&str>
Eat the current token if the argument starts with (at least) two dashes,
and the current token either matches
token
exactly, or starts with
token
followed by an equals sign. Read moreSource§fn eat_value<'a>(&mut self, token: &'a str) -> Option<&str>
fn eat_value<'a>(&mut self, token: &'a str) -> Option<&str>
Eat the current token if it matches
token
exactly. Read moreSource§fn eat_value_allows_leading_dashes<'a>(
&mut self,
token: &'a str,
) -> Option<&str>
fn eat_value_allows_leading_dashes<'a>( &mut self, token: &'a str, ) -> Option<&str>
Eat the current token (including any leading dashes) if it matches
token
exactly.Source§fn no_dash(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
fn no_dash(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
If the argument doesn’t start with dashes, returns a helper struct for
obtaining, validating and eating the next token.
Source§fn one_dash(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
fn one_dash(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
If the argument starts with a single dash, returns a helper struct for
obtaining, validating and eating the next token.
Source§fn two_dashes(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
fn two_dashes(&mut self) -> Option<InputPart<'_, Self>>where
Self: Sized,
If the argument starts with two (or more) dashes, returns a helper
struct for obtaining, validating and eating the next token.
Source§fn value_allows_leading_dashes(&mut self) -> Option<InputPartLD<'_, Self>>where
Self: Sized,
fn value_allows_leading_dashes(&mut self) -> Option<InputPartLD<'_, Self>>where
Self: Sized,
Returns a helper struct for obtaining, validating and eating the next
token. The value is allowed to start with a dash.
Auto Trait Implementations§
impl<I> Freeze for StringInput<I>where
I: Freeze,
impl<I> RefUnwindSafe for StringInput<I>where
I: RefUnwindSafe,
impl<I> Send for StringInput<I>where
I: Send,
impl<I> Sync for StringInput<I>where
I: Sync,
impl<I> Unpin for StringInput<I>where
I: Unpin,
impl<I> UnwindSafe for StringInput<I>where
I: 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