pub struct OptionSet<'r, 'a: 'r> {
pub long: &'r [LongOption<'a>],
pub short: &'r [ShortOption],
pub mode: OptionsMode,
pub allow_abbreviations: bool,
}
Expand description
Option set
Used to supply the set of information about available options to match against
This is the non-“extendible” variant. Unlike its cousin OptionSetEx
, this holds options lists
as slice references rather than Vec
s, and thus cannot be extended in size (hence no add_*
methods). This is particularly useful in efficient creation of static/const option sets.
Fields§
§long: &'r [LongOption<'a>]
§short: &'r [ShortOption]
§mode: OptionsMode
§allow_abbreviations: bool
Implementations§
source§impl<'r, 'a: 'r> OptionSet<'r, 'a>
impl<'r, 'a: 'r> OptionSet<'r, 'a>
sourcepub fn to_extendible(&self) -> OptionSetEx<'a>
pub fn to_extendible(&self) -> OptionSetEx<'a>
Creates an ‘extendible’ copy of self
This duplicates the options in self
into an OptionSetEx
.
sourcepub fn set_mode(&mut self, mode: OptionsMode) -> &mut Self
pub fn set_mode(&mut self, mode: OptionsMode) -> &mut Self
Set mode
sourcepub fn set_allow_abbreviations(&mut self, allow: bool) -> &mut Self
pub fn set_allow_abbreviations(&mut self, allow: bool) -> &mut Self
Enable/disable abbreviated matching
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks validity of option set
Returns true
if valid. Outputs details of problems found to stderr
.
sourcepub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>where
T: AsRef<str>,
pub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>where
T: AsRef<str>,
Analyses provided program arguments.
This is the same as calling the process
function directly.
Returns a result set describing the result of the analysis. This may include &str
references to strings provided in the args
and options
parameter data. Take note of this
with respect to object lifetimes.
Expects self
to be valid (see is_valid
).