pub struct Opt(pub char, pub Option<String>);
Expand description
A single option.
For Opt(x, y)
:
x
is the character representing the option.y
isSome
string, orNone
if no argument was expected.
§Example
use getopt::Opt;
// args = ["program", "-abc", "foo"];
let optstring = "ab:c";
let mut opts = getopt::Parser::new(&args, optstring);
assert_eq!(Opt('a', None), opts.next().transpose()?.unwrap());
assert_eq!(Opt('b', Some("c".to_string())), opts.next().transpose()?.unwrap());
assert_eq!(None, opts.next().transpose()?);
Tuple Fields§
§0: char
§1: Option<String>
Trait Implementations§
source§impl Ord for Opt
impl Ord for Opt
source§impl PartialOrd for Opt
impl PartialOrd for Opt
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 moreimpl Eq for Opt
impl StructuralPartialEq for Opt
Auto Trait Implementations§
impl Freeze for Opt
impl RefUnwindSafe for Opt
impl Send for Opt
impl Sync for Opt
impl Unpin for Opt
impl UnwindSafe for Opt
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more