fn process<F>(self, arg: &str, get_next_arg: F) -> Argument
    where
        F: FnOnce() -> Option<OsString>,
    {
        match self {
            ArgInfo::Flag(s) => {
                debug_assert_eq!(s, arg);
                Argument::Flag(s)
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::Separated) => {
                debug_assert_eq!(s, arg);
                if let Some(a) = get_next_arg() {
                    Argument::WithValue(s, t.process(a), ArgDisposition::Separated)
                } else {
                    Argument::Flag(s)
                }
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::Concatenated(d)) => {
                let mut len = s.len();
                debug_assert_eq!(&arg[..len], s);
                if let Some(d) = d {
                    debug_assert_eq!(arg.as_bytes()[len], d);
                    len += 1;
                }
                Argument::WithValue(
                    s,
                    t.process(arg[len..].into()),
                    ArgDisposition::Concatenated(d),
                )
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::CanBeSeparated(d)) |
            ArgInfo::TakeArg(s, t, ArgDisposition::CanBeConcatenated(d)) => {
                let derived = if arg == s {
                    ArgInfo::TakeArg(s, t, ArgDisposition::Separated)
                } else {
                    ArgInfo::TakeArg(s, t, ArgDisposition::Concatenated(d))
                };
                match derived.process(arg, get_next_arg) {
                    Argument::Flag(_) if d == None => {
                        Argument::WithValue(
                            s,
                            t.process("".into()),
                            ArgDisposition::Concatenated(d),
                        )
                    }
                    Argument::WithValue(s, v, ArgDisposition::Concatenated(d)) => {
                        Argument::WithValue(s, v, ArgDisposition::CanBeSeparated(d))
                    }
                    Argument::WithValue(s, v, ArgDisposition::Separated) => {
                        Argument::WithValue(s, v, ArgDisposition::CanBeConcatenated(d))
                    }
                    a => a,
                }
            }
        }
    }
/// Transform an argument description into a parsed Argument, given a
/// string. For arguments with a value, where the value is separate, the
/// `get_next_arg` function returns the next argument, in raw `OsString`
/// form.
Transform an argument description into a parsed Argument, given a
string. For arguments with a value, where the value is separate, the
`get_next_arg` function returns the next argument, in raw `OsString`
form.
Transform an argument description into a parsed Argument given a string . For arguments with a value where the value is separate the ` get_next_arg ` function returns the next argument in raw ` OsString ` form .
fn process<F>(self, arg: &str, get_next_arg: F) -> Argument
    where
        F: FnOnce() -> Option<OsString>,
    {
        match self {
            ArgInfo::Flag(s) => {
                debug_assert_eq!(s, arg);
                Argument::Flag(s)
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::Separated) => {
                debug_assert_eq!(s, arg);
                if let Some(a) = get_next_arg() {
                    Argument::WithValue(s, t.process(a), ArgDisposition::Separated)
                } else {
                    Argument::Flag(s)
                }
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::Concatenated(d)) => {
                let mut len = s.len();
                debug_assert_eq!(&arg[..len], s);
                if let Some(d) = d {
                    debug_assert_eq!(arg.as_bytes()[len], d);
                    len += 1;
                }
                Argument::WithValue(
                    s,
                    t.process(arg[len..].into()),
                    ArgDisposition::Concatenated(d),
                )
            }
            ArgInfo::TakeArg(s, t, ArgDisposition::CanBeSeparated(d)) |
            ArgInfo::TakeArg(s, t, ArgDisposition::CanBeConcatenated(d)) => {
                let derived = if arg == s {
                    ArgInfo::TakeArg(s, t, ArgDisposition::Separated)
                } else {
                    ArgInfo::TakeArg(s, t, ArgDisposition::Concatenated(d))
                };
                match derived.process(arg, get_next_arg) {
                    Argument::Flag(_) if d == None => {
                        Argument::WithValue(
                            s,
                            t.process("".into()),
                            ArgDisposition::Concatenated(d),
                        )
                    }
                    Argument::WithValue(s, v, ArgDisposition::Concatenated(d)) => {
                        Argument::WithValue(s, v, ArgDisposition::CanBeSeparated(d))
                    }
                    Argument::WithValue(s, v, ArgDisposition::Separated) => {
                        Argument::WithValue(s, v, ArgDisposition::CanBeConcatenated(d))
                    }
                    a => a,
                }
            }
        }
    }
fn process < F > ( self , arg : & str , get_next_arg : F ) -> Argument where F : FnOnce ( ) -> Option < OsString > , { match self { ArgInfo :: Flag ( s ) => { debug_assert_eq ! ( s arg ) ; Argument :: Flag ( s ) } ArgInfo :: TakeArg ( s , t , ArgDisposition :: Separated ) => { debug_assert_eq ! ( s arg ) ; if let Some ( a ) = get_next_arg ( ) { Argument :: WithValue ( s , t . process ( a ) , ArgDisposition :: Separated ) } else { Argument :: Flag ( s ) } } ArgInfo :: TakeArg ( s , t , ArgDisposition :: Concatenated ( d ) ) => { let mut len = s . len ( ) ; debug_assert_eq ! ( arg [ len ] s ) ; if let Some ( d ) = d { debug_assert_eq ! ( arg as_bytes ( ) [ len ] d ) ; len += 1 ; } Argument :: WithValue ( s , t . process ( arg [ len .. ] . into ( ) ) , ArgDisposition :: Concatenated ( d ) , ) } ArgInfo :: TakeArg ( s , t , ArgDisposition :: CanBeSeparated ( d ) ) | ArgInfo :: TakeArg ( s , t , ArgDisposition :: CanBeConcatenated ( d ) ) => { let derived = if arg == s { ArgInfo :: TakeArg ( s , t , ArgDisposition :: Separated ) } else { ArgInfo :: TakeArg ( s , t , ArgDisposition :: Concatenated ( d ) ) } ; match derived . process ( arg , get_next_arg ) { Argument :: Flag ( _ ) if d == None => { Argument :: WithValue ( s , t . process ( " " . into ( ) ) , ArgDisposition :: Concatenated ( d ) , ) } Argument :: WithValue ( s , v , ArgDisposition :: Concatenated ( d ) ) => { Argument :: WithValue ( s , v , ArgDisposition :: CanBeSeparated ( d ) ) } Argument :: WithValue ( s , v , ArgDisposition :: Separated ) => { Argument :: WithValue ( s , v , ArgDisposition :: CanBeConcatenated ( d ) ) } a => a , } } } }
Transform an argument description into a parsed Argument, given a
string.
Transform an argument description into a parsed Argument given a string .
self
arg
&str
get_next_arg
F