Enum docopt::Value[][src]

pub enum Value {
    Switch(bool),
    Counted(u64),
    Plain(Option<String>),
    List(Vec<String>),
}
Expand description

A matched command line value.

The value can be a boolean, counted repetition, a plain string or a list of strings.

The various as_{bool,count,str,vec} methods provide convenient access to values without destructuring manually.

Variants

Switch

A boolean value from a flag that has no argument.

The presence of a flag means true and the absence of a flag means false.

Tuple Fields of Switch

0: bool
Counted

The number of occurrences of a repeated flag.

Tuple Fields of Counted

0: u64
Plain

A positional or flag argument.

This is None when the positional argument or flag is not present. Note that it is possible to have Some("") for a present but empty argument.

Tuple Fields of Plain

0: Option<String>
List

A List of positional or flag arguments.

This list may be empty when no arguments or flags are present.

Tuple Fields of List

0: Vec<String>

Implementations

Returns the value as a bool.

Counted repetitions are false if 0 and true otherwise. Plain strings are true if present and false otherwise. Lists are true if non-empty and false otherwise.

Returns the value as a count of the number of times it occurred.

Booleans are 1 if true and 0 otherwise. Plain strings are 1 if present and 0 otherwise. Lists correspond to its length.

Returns the value as a string.

All values return an empty string except for a non-empty plain string.

Returns the value as a list of strings.

Booleans, repetitions and empty strings correspond to an empty list. Plain strings correspond to a list of length 1.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.