Skip to main content

Arg

Struct Arg 

Source
pub struct Arg<'a> {
    pub key: u64,
    pub required: bool,
    pub var: bool,
    pub var_max: Option<u32>,
    pub delimiter: Option<u8>,
    pub allow_negative_numbers: bool,
    pub value_terminator: Option<&'a [u8]>,
    pub double_dash: DoubleDash,
    pub name: &'a str,
}
Expand description

A positional argument.

Fields§

§key: u64

Caller-assigned identifier, echoed back in Event::Arg. See Command::key on why it is this wide.

§required: bool

Whether post-binding requires this positional to have a value. Kept in the hot table because allow_missing_positional must reserve words for later required args.

§var: bool

Whether this argument keeps taking values once it has one.

§var_max: Option<u32>

How many words a variadic may take before the next argument gets the rest.

A bound belongs here, in the table binding reads, rather than with the metadata: it decides where a word lands, not whether what landed is acceptable. clap’s num_args works the same way, and every spec in the wild is generated from a clap command. u32 rather than usize because a CLI that bounds a variadic above four billion has other problems, and this table is read on the hot path.

§delimiter: Option<u8>

The byte that makes one word several values, if the argument declares one.

See Flag::delimiter: a bound counts values, and only this says how many values a word carries.

§allow_negative_numbers: bool

Whether a negative-number token is accepted as this positional even in strict flag mode.

§value_terminator: Option<&'a [u8]>

A token that ends this variadic positional without becoming a value.

§double_dash: DoubleDash

This argument’s relationship to the -- separator.

§name: &'a str

Unused by binding, kept so a table entry can carry its own name for diagnostics.

Implementations§

Source§

impl Arg<'_>

Source

pub const REQUIRED: Arg<'static>

A single-value argument, for use with struct update syntax.

Source

pub const VAR: Arg<'static>

A variadic argument, for use with struct update syntax.

Trait Implementations§

Source§

impl<'a> Clone for Arg<'a>

Source§

fn clone(&self) -> Arg<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Arg<'a>

Source§

impl<'a> Debug for Arg<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Arg<'a>

Source§

impl<'a> PartialEq for Arg<'a>

Source§

fn eq(&self, other: &Arg<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Arg<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Arg<'a>

§

impl<'a> RefUnwindSafe for Arg<'a>

§

impl<'a> Send for Arg<'a>

§

impl<'a> Sync for Arg<'a>

§

impl<'a> Unpin for Arg<'a>

§

impl<'a> UnsafeUnpin for Arg<'a>

§

impl<'a> UnwindSafe for Arg<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.