Skip to main content

Item

Struct Item 

Source
pub struct Item {
Show 26 fields pub short: Option<char>, pub long: Option<&'static str>, pub aliases: &'static [&'static str], pub negate: Option<&'static str>, pub value_name: Option<&'static str>, pub help: &'static str, pub long_help: &'static str, pub heading: Option<&'static str>, pub hide: bool, pub positional: bool, pub required: bool, pub multiple: bool, pub trailing: bool, pub default: Option<&'static str>, pub env: Option<&'static str>, pub choices: &'static [&'static str], pub require_equals: bool, pub global: bool, pub more_shorts: &'static [char], pub plus: Option<char>, pub optional_value: bool, pub values: usize, pub more_values: bool, pub hint: Hint, pub complete: Option<fn(&str) -> Vec<Candidate>>, pub warning: &'static str,
}
Expand description

A flag or positional.

Fields§

§short: Option<char>

-c.

§long: Option<&'static str>

--name.

§aliases: &'static [&'static str]

Other long names it answers to, not shown.

§negate: Option<&'static str>

--no-name, the spelling that sets it false.

§value_name: Option<&'static str>

The value’s placeholder; None for a switch.

§help: &'static str

First paragraph of the description.

§long_help: &'static str

The whole description.

§heading: Option<&'static str>

Section to list it under instead of “Options”.

§hide: bool

Left out of help.

§positional: bool

A positional rather than a flag.

§required: bool

Must be given.

§multiple: bool

Takes several values or occurrences.

§trailing: bool

A positional that only takes words after --.

§default: Option<&'static str>

The value used when none is given.

§env: Option<&'static str>

The environment variable consulted.

§choices: &'static [&'static str]

The only values accepted.

§require_equals: bool

The value is only taken attached (--name=value), never the next word.

§global: bool

Also accepted by every subcommand below.

§more_shorts: &'static [char]

Other letters it answers to: -l, -L.

§plus: Option<char>

The letter of its +c spelling.

§optional_value: bool

The value may be left out.

§values: usize

Words each occurrence takes; 1 unless declared values = N.

§more_values: bool

It may take more than values (values = 1..): shown as <V>....

§hint: Hint

What its value is, for the shell that completes it.

§complete: Option<fn(&str) -> Vec<Candidate>>

What its value can be, given what is typed of it: asked when a shell completes it, in place of its choices and its hint.

§warning: &'static str

What to know before using it, shown by --help as Warning: …; empty for none.

Implementations§

Source§

impl Item

Source

pub const EMPTY: Item

A switch with no name. A value written by hand ends in ..Item::EMPTY, and a release that adds a field does not break it.

Trait Implementations§

Source§

impl Clone for Item

Source§

fn clone(&self) -> Self

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 Copy for Item

Source§

impl Debug for Item

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Item

§

impl RefUnwindSafe for Item

§

impl Send for Item

§

impl Sync for Item

§

impl Unpin for Item

§

impl UnsafeUnpin for Item

§

impl UnwindSafe for Item

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, !>

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.