Struct ValuesRef

pub struct ValuesRef<'a, T> { /* private fields */ }

Iterate over multiple values for an argument via ArgMatches::get_many.

Examples

# use clap_builder as clap;
# use clap::{Command, Arg, ArgAction};
let m = Command::new("myapp")
    .arg(Arg::new("output")
        .short('o')
        .action(ArgAction::Append))
    .get_matches_from(vec!["myapp", "-o", "val1", "-o", "val2"]);

let mut values = m.get_many::<String>("output")
    .unwrap()
    .map(|s| s.as_str());

assert_eq!(values.next(), Some("val1"));
assert_eq!(values.next(), Some("val2"));
assert_eq!(values.next(), None);

Trait Implementations

impl<'a, T: 'a> Default for ValuesRef<'a, T>

fn default() -> Self

impl<'a, T: 'a> DoubleEndedIterator for ValuesRef<'a, T>

fn next_back(&mut self) -> Option<Self::Item>

impl<'a, T: 'a> ExactSizeIterator for ValuesRef<'a, T>

impl<'a, T: 'a> Iterator for ValuesRef<'a, T>

type Item = &'a T;
fn next(&mut self) -> Option<Self::Item>
fn size_hint(&self) -> (usize, Option<usize>)

impl<'a, T: Clone> Clone for ValuesRef<'a, T>

fn clone(&self) -> ValuesRef<'a, T>

impl<'a, T: Debug> Debug for ValuesRef<'a, T>

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

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for ValuesRef<'a, T>

impl<'a, T> !UnwindSafe for ValuesRef<'a, T>

impl<'a, T> Freeze for ValuesRef<'a, T> where Map<Flatten<Iter<'a, Vec<AnyValue>>>, fn(&AnyValue) -> &T>: Freeze,

impl<'a, T> Send for ValuesRef<'a, T> where Map<Flatten<Iter<'a, Vec<AnyValue>>>, fn(&AnyValue) -> &T>: Send,

impl<'a, T> Sync for ValuesRef<'a, T> where Map<Flatten<Iter<'a, Vec<AnyValue>>>, fn(&AnyValue) -> &T>: Sync,

impl<'a, T> Unpin for ValuesRef<'a, T> where Map<Flatten<Iter<'a, Vec<AnyValue>>>, fn(&AnyValue) -> &T>: Unpin,

impl<'a, T> UnsafeUnpin for ValuesRef<'a, T> where Map<Flatten<Iter<'a, Vec<AnyValue>>>, fn(&AnyValue) -> &T>: UnsafeUnpin,

Blanket Implementations

impl<I> IntoIterator for ValuesRef<'a, T> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for ValuesRef<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for ValuesRef<'a, T> where T: ?Sized,

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

impl<T> CloneToUninit for ValuesRef<'a, T> where T: Clone,

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

impl<T> From<T> for ValuesRef<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ValuesRef<'a, T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for ValuesRef<'a, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for ValuesRef<'a, T> where U: Into<T>,

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

impl<T, U> TryInto<U> for ValuesRef<'a, T> where U: TryFrom<T>,

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