Expand description
The current state of the parser.
args[index]
is the current element being parsed.
args[index][point]
is the current character being parsed.
After parsing is complete (that is, Opt(None, None)
is returned), any remaining arguments can
be found in args
beginning at index
.
Example
use getopt::*;
// args = ["program", "-abc", "foo"];
let optstring = "ab:c";
let mut state = State::new();
getopt(&args, optstring, &mut state).unwrap();
assert_eq!(State { index: 1, point: 2 }, state);
getopt(&args, optstring, &mut state).unwrap();
assert_eq!(State { index: 2, point: 0 }, state);
getopt(&args, optstring, &mut state).unwrap();
assert_eq!(State { index: 2, point: 0 }, state);
assert_eq!("foo", args[state.index]);
Fields§
§index: usize
§point: usize
Implementations§
Trait Implementations§
source§impl Ord for State
impl Ord for State
source§impl PartialOrd<State> for State
impl PartialOrd<State> for State
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more