refactor(lex): Clarify side effects

This commit is contained in:
Ed Page 2022-04-14 16:08:50 -05:00
parent fd16ee9474
commit 6148d681f4
2 changed files with 5 additions and 5 deletions

View file

@ -212,7 +212,7 @@ impl<'s> ShortFlags<'s> {
self.invalid_suffix.is_none() && self.utf8_prefix.as_str().parse::<f64>().is_ok()
}
pub fn next(&mut self) -> Option<Result<char, &'s RawOsStr>> {
pub fn next_flag(&mut self) -> Option<Result<char, &'s RawOsStr>> {
if let Some((_, flag)) = self.utf8_prefix.next() {
return Some(Ok(flag));
}
@ -225,7 +225,7 @@ impl<'s> ShortFlags<'s> {
None
}
pub fn value_os(&mut self) -> Option<&'s RawOsStr> {
pub fn next_value_os(&mut self) -> Option<&'s RawOsStr> {
if let Some((index, _)) = self.utf8_prefix.next() {
self.utf8_prefix = "".char_indices();
self.invalid_suffix = None;
@ -245,7 +245,7 @@ impl<'s> Iterator for ShortFlags<'s> {
type Item = Result<char, &'s RawOsStr>;
fn next(&mut self) -> Option<Self::Item> {
self.next()
self.next_flag()
}
}

View file

@ -969,7 +969,7 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
"tracking of `flag_subcmd_skip` is off for `{:?}`",
short_arg
);
while let Some(c) = short_arg.next() {
while let Some(c) = short_arg.next_flag() {
let c = match c {
Ok(c) => c,
Err(rest) => {
@ -1010,7 +1010,7 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
// Check for trailing concatenated value
//
// Cloning the iterator, so we rollback if it isn't there.
let val = short_arg.clone().value_os().unwrap_or_default();
let val = short_arg.clone().next_value_os().unwrap_or_default();
debug!(
"Parser::parse_short_arg:iter:{}: val={:?} (bytes), val={:?} (ascii), short_arg={:?}",
c, val, val.as_raw_bytes(), short_arg