Struct ArgumentList

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

List of arguments of an option or command.

Implementations§

Source§

impl ArgumentList

Source

pub fn new() -> Self

Constructs a new ArgumentList.

Source

pub fn len(&self) -> usize

Returns the number of arguments.

Source

pub fn is_empty(&self) -> bool

Returns true if there is no arguments.

Source

pub fn add(&mut self, arg: Argument) -> Result<(), Argument>

Adds an argument to the list, returns true if the argument was added otherwise if is a duplicate returns false.

§Panics:

Panics if there is multiples options with default values.

Source

pub fn get<S: AsRef<str>>(&self, arg_name: S) -> Option<&Argument>

Returns the Argument with the given name or None if no found.

Source

pub fn get_raw_args(&self) -> RawArgs<'_>

Returns an iterator over the &str values of this ArgumentList.

Source

pub fn get_raw_args_as_type<T>(&self) -> Result<Vec<T>>
where T: FromStr + 'static, <T as FromStr>::Err: Display,

Returns the values of all the arguments of this ArgumentList and convert them to type T.

§Error

If one of the value cannot be parse to T.

Source

pub fn contains<S: AsRef<str>>(&self, arg_name: S) -> bool

Returns true if contains an argument with the given name.

Source

pub fn convert<T>(&self, arg_name: &str) -> Result<T>
where T: FromStr + 'static, <T as FromStr>::Err: Display,

Converts the value of the Argument with the given name.

§Returns
  • Ok(T) : If the String value of the argument can be parse to T.
  • Err(error):
    • If the argument cannot be found.
    • If the value cannot be parse.
    • if there no value to parse.
    • if there is more than 1 value.
Source

pub fn convert_at<T>(&self, index: usize) -> Result<T>
where T: FromStr + 'static, <T as FromStr>::Err: Display,

Converts the value of the Argument with the given index.

§Panics

If the index is out of bounds.

§Returns
  • Ok(T) : If the String value of the argument can be parse to T.
  • Err(error):
    • If the value cannot be parse.
    • if there no value to parse.
    • if there is more than 1 value.
Source

pub fn convert_all<T>(&self, arg_name: &str) -> Result<Vec<T>>
where T: FromStr + 'static, <T as FromStr>::Err: Display,

Converts all values of the Argument with the given name.

§Returns
  • Ok(Vec<T>) : If all the values can be parsed to T.
  • Err(error):
    • If the argument cannot be found.
    • If one of the values cannot be parse.
    • if there no values to parse.
Source

pub fn clear(&mut self)

Removes all the Arguments.

Source

pub fn iter(&self) -> Iter<'_>

Returns an Iterator over the arguments.

Trait Implementations§

Source§

impl Clone for ArgumentList

Source§

fn clone(&self) -> ArgumentList

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ArgumentList

Source§

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

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

impl Default for ArgumentList

Source§

fn default() -> ArgumentList

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ArgumentList

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Index<&str> for ArgumentList

Source§

type Output = Argument

The returned type after indexing.
Source§

fn index(&self, arg_name: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<String> for ArgumentList

Source§

type Output = Argument

The returned type after indexing.
Source§

fn index(&self, arg_name: String) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for ArgumentList

Source§

type Output = Argument

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a ArgumentList

Source§

type Item = &'a Argument

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for ArgumentList

Source§

type Item = Argument

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ArgumentList

Source§

fn eq(&self, other: &ArgumentList) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ArgumentList

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ArgumentList

Source§

impl StructuralPartialEq for ArgumentList

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> 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 = 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,