pub struct ParsedArgs {
pub flags: HashSet<String>,
pub options: HashMap<String, String>,
pub positional: Vec<String>,
}Expand description
Represents a set of parsed arguments.
You get this struct back after a successful call to Parser::parse().
Fields§
§flags: HashSet<String>A set of all flags that were present.
options: HashMap<String, String>A map of all options and their string values.
positional: Vec<String>A vector of all positional arguments in the order they appeared.
Implementations§
Source§impl ParsedArgs
impl ParsedArgs
Sourcepub fn get_value_as<T: FromStr>(&self, name: &str) -> Option<Result<T, T::Err>>
pub fn get_value_as<T: FromStr>(&self, name: &str) -> Option<Result<T, T::Err>>
Gets and parses the value of an option into a specific type.
This method attempts to find an option by its name and then parse its
string value into any type T that implements FromStr.
§Returns
None: If the option was not provided by the user.Some(Ok(value)): If the option was found and successfully parsed.Some(Err(error)): If the option was found but parsing failed.
§Examples
// Assuming `results` is a ParsedArgs
// let port = results.get_value_as::<u32>("port");Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParsedArgs
impl RefUnwindSafe for ParsedArgs
impl Send for ParsedArgs
impl Sync for ParsedArgs
impl Unpin for ParsedArgs
impl UnwindSafe for ParsedArgs
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