Expand description
A matched command line value.
The value can be a boolean, counted repetition, a plain string or a list of strings.
The various as_{bool,count,str,vec}
methods provide convenient access
to values without destructuring manually.
Variants
Switch(bool)
A boolean value from a flag that has no argument.
The presence of a flag means true
and the absence of a flag
means false
.
Counted(u64)
The number of occurrences of a repeated flag.
Plain(Option<String>)
A positional or flag argument.
This is None
when the positional argument or flag is not present.
Note that it is possible to have Some("")
for a present but empty
argument.
List(Vec<String>)
A List of positional or flag arguments.
This list may be empty when no arguments or flags are present.
Implementations
sourceimpl Value
impl Value
sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
Returns the value as a bool.
Counted repetitions are false
if 0
and true
otherwise.
Plain strings are true
if present and false
otherwise.
Lists are true
if non-empty and false
otherwise.
sourcepub fn as_count(&self) -> u64
pub fn as_count(&self) -> u64
Returns the value as a count of the number of times it occurred.
Booleans are 1
if true
and 0
otherwise.
Plain strings are 1
if present and 0
otherwise.
Lists correspond to its length.
Trait Implementations
impl StructuralPartialEq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more