[−][src]Struct lhlist::iter::ConsIterator
An iterator over a heterogeneous cons-list (Cons);
For a version that iterates over only the values of a labeled cons-list (LVCons), see ValuesIterator.
This object is usually created by calling iter on a list.
Example
This example demonstrates building and iterating over the LabeledValues of a heterogeneous cons-list.
use lhlist::{Label, labeled}; 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(); let (item, iter) = iter.next(); assert_eq!(item, &labeled(Label1, vec![8usize, 4, 1, 5, 2])); let (item, iter) = iter.next(); assert_eq!(item, &labeled(Label2, vec!["Hello", "World!"])); let (item, _) = iter.next(); assert_eq!(item, &labeled(Label3, vec![0.4f64, -3.5, 3.5, 0.3]));
Methods
impl<'a, List> ConsIterator<'a, List>
[src]
impl<'a, List, A> ConsIterator<'a, List, A>
[src]
pub fn with_adapter(list: &'a List, adapter: A) -> Self
[src]
Creates a new ConsIterator
over an Cons
-list with an adapter (see
Adapter).
impl<'a, H, T, A> ConsIterator<'a, Cons<H, T>, A> where
A: Adapter<&'a H>,
[src]
A: Adapter<&'a H>,
pub fn next(self) -> (<A as Adapter<&'a H>>::Output, ConsIterator<'a, T, A>)
[src]
Returns the next value (if exists) along with a new iterator advanced to the next element of the list.
pub fn map<F>(
self,
f: F
) -> ConsIterator<'a, Cons<H, T>, Cons<MapAdapter<F>, A>> where
F: MapFunc<<A as Adapter<&'a H>>::Output>,
[src]
self,
f: F
) -> ConsIterator<'a, Cons<H, T>, Cons<MapAdapter<F>, A>> where
F: MapFunc<<A as Adapter<&'a H>>::Output>,
Creates an iterator which call a MapFunc on each element.
See MapAdapter for more information.
pub fn collect_into_labeled_hlist<LabelList>(self) -> Self::Output where
Self: CollectIntoLabeledHList<LabelList>,
[src]
Self: CollectIntoLabeledHList<LabelList>,
Collects this iterator into a new labeled heterogeneous list
For an example of usage, see the MapAdapter example.
Trait Implementations
impl<'a, A> CollectIntoHList for ConsIterator<'a, Nil, A>
[src]
impl<'a, A, H, T> CollectIntoHList for ConsIterator<'a, Cons<H, T>, A> where
A: Adapter<&'a H>,
ConsIterator<'a, T, A>: CollectIntoHList,
[src]
A: Adapter<&'a H>,
ConsIterator<'a, T, A>: CollectIntoHList,
type Output = Cons<<A as Adapter<&'a H>>::Output, <ConsIterator<'a, T, A> as CollectIntoHList>::Output>
Output type of collected list
fn collect_into_hlist(self) -> Self::Output
[src]
impl<'a, A> CollectIntoLabeledHList<Nil> for ConsIterator<'a, Nil, A>
[src]
type Output = Nil
Output type of collected list
fn collect_into_labeled_hlist(self) -> Self::Output
[src]
impl<'a, TargetL, TargetT, A, L, T> CollectIntoLabeledHList<Cons<PhantomData<TargetL>, TargetT>> for ConsIterator<'a, LVCons<L, T>, A> where
L: Label,
TargetL: Label,
A: Adapter<&'a LabeledValue<L>, Output = TargetL::AssocType>,
ConsIterator<'a, T, A>: CollectIntoLabeledHList<TargetT>,
[src]
L: Label,
TargetL: Label,
A: Adapter<&'a LabeledValue<L>, Output = TargetL::AssocType>,
ConsIterator<'a, T, A>: CollectIntoLabeledHList<TargetT>,
type Output = LVCons<TargetL, <ConsIterator<'a, T, A> as CollectIntoLabeledHList<TargetT>>::Output>
Output type of collected list
fn collect_into_labeled_hlist(self) -> Self::Output
[src]
impl<'a, List: Debug, A: Debug> Debug for ConsIterator<'a, List, A>
[src]
Auto Trait Implementations
impl<'a, List, A> Send for ConsIterator<'a, List, A> where
A: Send,
List: Sync,
A: Send,
List: Sync,
impl<'a, List, A> Sync for ConsIterator<'a, List, A> where
A: Sync,
List: Sync,
A: Sync,
List: Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self