pub struct ValuesIterator<'a, List, A = Nil> { /* private fields */ }Expand description
An iterator over a labeled heterogeneous cons-list (LVCons) that only provides access to the contained values (as opposed to the LabeledValue object).
For a version that iterates over a cons-list (Cons) without stripping labeled information, see ConsIterator.
This object is usually created by calling iter_values on a list.
§Example
This example demonstrates building and iterating over the values of a labeled heterogeneous cons-list.
use lhlist::Label;
new_label![Label1: Vec<usize>];
new_label![Label2: Vec<&'static str>];
new_label![Label3: Vec<f64>];
let test_list = lhlist![
Label1 = vec![8usize, 4, 1, 5, 2],
Label2 = vec!["Hello", "World!"],
Label3 = vec![0.4f64, -3.5, 3.5, 0.3],
];
let iter = test_list.iter_values();
let (item, iter) = iter.next();
assert_eq!(item, &vec![8usize, 4, 1, 5, 2]);
let (item, iter) = iter.next();
assert_eq!(item, &vec!["Hello", "World!"]);
let (item, _) = iter.next();
assert_eq!(item, &vec![0.4f64, -3.5, 3.5, 0.3]);Implementations§
Source§impl<'a, List> ValuesIterator<'a, List>
impl<'a, List> ValuesIterator<'a, List>
Source§impl<'a, List, A> ValuesIterator<'a, List, A>
impl<'a, List, A> ValuesIterator<'a, List, A>
Sourcepub fn with_adapter(list: &'a List, adapter: A) -> Self
pub fn with_adapter(list: &'a List, adapter: A) -> Self
Creates a new ValuesIterator over an LVCons-list with a specified adapter (see
Adapter).
Source§impl<'a, L, T, A> ValuesIterator<'a, LVCons<L, T>, A>
impl<'a, L, T, A> ValuesIterator<'a, LVCons<L, T>, A>
Sourcepub fn next(
self,
) -> (<A as Adapter<&'a L::AssocType>>::Output, ValuesIterator<'a, T, A>)
pub fn next( self, ) -> (<A as Adapter<&'a L::AssocType>>::Output, ValuesIterator<'a, T, A>)
Returns the next value (if exists) along with a new iterator advanced to the next element of the list.
Sourcepub fn map<F>(
self,
f: F,
) -> ValuesIterator<'a, LVCons<L, T>, Cons<MapAdapter<F>, A>>
pub fn map<F>( self, f: F, ) -> ValuesIterator<'a, LVCons<L, T>, Cons<MapAdapter<F>, A>>
Creates an iterator which call a MapFunc on each element.
See MapAdapter for more information.
Sourcepub fn collect_into_labeled_hlist<LabelList>(
self,
) -> <Self as CollectIntoLabeledHList<LabelList>>::Outputwhere
Self: CollectIntoLabeledHList<LabelList>,
pub fn collect_into_labeled_hlist<LabelList>(
self,
) -> <Self as CollectIntoLabeledHList<LabelList>>::Outputwhere
Self: CollectIntoLabeledHList<LabelList>,
Collects this iterator into a new labeled heterogeneous list
For an example of usage, see the MapAdapter example.