OptRule

Struct OptRule 

Source
pub struct OptRule { /* private fields */ }
Expand description

A parsing rule that describes one option. This includes the following metadata:

  • name: internal lookup name.
  • long: optional long form (for example verbose).
  • short: optional short form (for example v).
  • val_count: number of following values. Zero means this is a flag.

Implementations§

Source§

impl OptRule

Source

pub const fn new(name: &'static str) -> OptRule

Creates an OptRule with name. No short or long identifier is set.

Source

pub const fn new_auto_long(name: &'static str) -> OptRule

Creates an OptRule whose long identifier equals name.

Source

pub const fn new_auto(name: &'static str) -> OptRule

Creates an OptRule with long equal to name and short set to the first character of name.

Source

pub const fn set_long(self, long: &'static str) -> OptRule

Sets the long identifier.

Source

pub const fn set_short(self, short: char) -> OptRule

Sets the short identifier.

Source

pub const fn set_val_count(self, val_count: usize) -> OptRule

Sets the number of values this option accepts.

Source

pub const fn name(&self) -> &'static str

Returns the rule’s internal name.

Source

pub fn long(&self) -> Option<&'static str>

Returns the long identifier, if any.

Source

pub const fn short(&self) -> Option<char>

Returns the short identifier, if any.

Source

pub const fn val_count(&self) -> usize

Returns how many values this option accepts.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.