pub struct Matches {
pub free: Vec<String>,
/* private fields */
}
Expand description
The result of checking command line arguments. Contains a vector of matches and a vector of free strings.
Fields§
§free: Vec<String>
Free string fragments
Implementations§
source§impl Matches
impl Matches
sourcepub fn opt_defined(&self, nm: &str) -> bool
pub fn opt_defined(&self, nm: &str) -> bool
Returns true if an option was defined
sourcepub fn opt_present(&self, nm: &str) -> bool
pub fn opt_present(&self, nm: &str) -> bool
Returns true if an option was matched.
sourcepub fn opt_positions(&self, nm: &str) -> Vec<usize>
pub fn opt_positions(&self, nm: &str) -> Vec<usize>
Returns a vector of all the positions in which an option was matched.
sourcepub fn opts_present(&self, names: &[String]) -> bool
pub fn opts_present(&self, names: &[String]) -> bool
Returns true if any of several options were matched.
sourcepub fn opts_str(&self, names: &[String]) -> Option<String>
pub fn opts_str(&self, names: &[String]) -> Option<String>
Returns the string argument supplied to one of several matching options or None
.
sourcepub fn opt_strs(&self, nm: &str) -> Vec<String>
pub fn opt_strs(&self, nm: &str) -> Vec<String>
Returns a vector of the arguments provided to all matches of the given option.
Used when an option accepts multiple values.
sourcepub fn opt_strs_pos(&self, nm: &str) -> Vec<(usize, String)>
pub fn opt_strs_pos(&self, nm: &str) -> Vec<(usize, String)>
Returns a vector of the arguments provided to all matches of the given option, together with their positions.
Used when an option accepts multiple values.
sourcepub fn opt_str(&self, nm: &str) -> Option<String>
pub fn opt_str(&self, nm: &str) -> Option<String>
Returns the string argument supplied to a matching option or None
.
sourcepub fn opt_default(&self, nm: &str, def: &str) -> Option<String>
pub fn opt_default(&self, nm: &str, def: &str) -> Option<String>
Returns the matching string, a default, or None
.
Returns None
if the option was not present, def
if the option was
present but no argument was provided, and the argument if the option was
present and an argument was provided.
sourcepub fn opt_get<T>(&self, nm: &str) -> Result<Option<T>, T::Err>where
T: FromStr,
pub fn opt_get<T>(&self, nm: &str) -> Result<Option<T>, T::Err>where
T: FromStr,
Returns some matching value or None
.
Similar to opt_str, also converts matching argument using FromStr.
sourcepub fn opt_get_default<T>(&self, nm: &str, def: T) -> Result<T, T::Err>where
T: FromStr,
pub fn opt_get_default<T>(&self, nm: &str, def: T) -> Result<T, T::Err>where
T: FromStr,
Returns a matching value or default.
Similar to opt_default, except the two differences.
Instead of returning None when argument was not present, return def
.
Instead of returning &str return type T, parsed using str::parse().
Trait Implementations§
impl Eq for Matches
impl StructuralPartialEq for Matches
Auto Trait Implementations§
impl Freeze for Matches
impl RefUnwindSafe for Matches
impl Send for Matches
impl Sync for Matches
impl Unpin for Matches
impl UnwindSafe for Matches
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)