[][src]Struct getopt::State

pub struct State {
    pub index: usize,
    pub point: usize,
}

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: usizepoint: 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 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]

impl Debug for State[src]

Auto Trait Implementations

impl Send for State

impl Sync for State

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.