[−][src]Struct getopt::State
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::prelude::*; // args = ["program", "-abc", "foo"]; let optstring = "ab:c"; let mut state = State::new(); getopt(&args, optstring, &mut state)?; assert_eq!(State { index: 1, point: 2 }, state); getopt(&args, optstring, &mut state)?; assert_eq!(State { index: 2, point: 0 }, state); getopt(&args, optstring, &mut state)?; assert_eq!(State { index: 2, point: 0 }, state); assert_eq!("foo", args[state.index]);
Fields
index: usize
point: usize
Methods
impl State
[src]
pub fn new() -> State
[src]
Constructs a new State
, with index
and point
initialized to 1 and
0, respectively.
Trait Implementations
impl PartialEq<State> for State
[src]
impl Default for State
[src]
impl Ord for State
[src]
fn cmp(&self, other: &State) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Eq for State
[src]
impl PartialOrd<State> for State
[src]
fn partial_cmp(&self, other: &State) -> Option<Ordering>
[src]
fn lt(&self, other: &State) -> bool
[src]
fn le(&self, other: &State) -> bool
[src]
fn gt(&self, other: &State) -> bool
[src]
fn ge(&self, other: &State) -> bool
[src]
impl Debug for State
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,