pub struct CliOption { /* private fields */ }Expand description
A primitive command-line key/value option.
Implementations§
Source§impl CliOption
impl CliOption
Sourcepub const fn new(name: CliOptionName, value: OptionValue) -> Self
pub const fn new(name: CliOptionName, value: OptionValue) -> Self
Creates a CLI option from an already validated name and owned value.
Sourcepub fn from_name_value(
name: &str,
value: impl Into<String>,
) -> Result<Self, CliOptionError>
pub fn from_name_value( name: &str, value: impl Into<String>, ) -> Result<Self, CliOptionError>
Creates a CLI option from a name and value pair, such as --key value.
§Errors
Returns CliOptionError when name is not a valid option name.
Sourcepub fn from_equals_token(token: &str) -> Result<Self, CliOptionError>
pub fn from_equals_token(token: &str) -> Result<Self, CliOptionError>
Creates a CLI option from a token like --key=value.
§Errors
Returns CliOptionError when the token does not use --key=value form.
Sourcepub const fn name(&self) -> &CliOptionName
pub const fn name(&self) -> &CliOptionName
Returns the option name.
Sourcepub const fn value(&self) -> &OptionValue
pub const fn value(&self) -> &OptionValue
Returns the option value.
Sourcepub fn to_equals_token(&self) -> String
pub fn to_equals_token(&self) -> String
Returns the --key=value token form.
Trait Implementations§
impl Eq for CliOption
impl StructuralPartialEq for CliOption
Auto Trait Implementations§
impl Freeze for CliOption
impl RefUnwindSafe for CliOption
impl Send for CliOption
impl Sync for CliOption
impl Unpin for CliOption
impl UnsafeUnpin for CliOption
impl UnwindSafe for CliOption
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