[−][src]Struct lhlist::Cons
Main buildling block of a heterogeneous list.
Fields
head: H
Value of this element of the list.
tail: T
Remaining elements of the list.
Methods
impl<Head, Tail> Cons<Head, Tail>
[src]
pub fn iter<'a>(&'a self) -> ConsIterator<'a, Self>
[src]
Returns a iterator over this cons-list.
pub fn has_label<TargetL>(&self, _target_label: TargetL) -> bool where
Self: Member<TargetL>,
[src]
Self: Member<TargetL>,
Returns true
if target label exists in this list.
Convenience function for calling
has_label_typearg
without needing to specify type argument. Calling list.has_label(ExampleLabel)
is
equivalent to list.has_label_typearg::<ExampleLabel>())
.
pub fn has_label_typearg<TargetL>(&self) -> bool where
Self: Member<TargetL>,
[src]
Self: Member<TargetL>,
Returns true
if target label exists in this list.
Calling list.has_label(ExampleLabel)
is equivalent to
list.has_label_typearg::<ExampleLabel>())
.
pub fn iter_values<'a>(&'a self) -> ValuesIterator<'a, Self>
[src]
Returns a iterator over this labeled cons-list which iterates over the lists' values (i.e.
object of type Value
).
See ValuesIterator for an example.
pub fn elem<TargetL>(&self) -> &Self::Elem where
Self: LookupElemByLabel<TargetL>,
[src]
Self: LookupElemByLabel<TargetL>,
Returns a reference the element labeled by a specific label.
Example
use lhlist::labeled; new_label![Label1: u8]; new_label![Label2: i8]; new_label![Label3: bool]; let list = lhlist![ Label1 = 9, Label2 = -4, Label3 = true, ]; // assert_eq!(list[Label1], labeled(Label1, 9)); assert_eq!(list.elem::<Label1>(), &labeled(Label1, 9)); // assert_eq!(list[Label2], labeled(Label2, -4)); assert_eq!(list.elem::<Label2>(), &labeled(Label2, -4)); // assert_eq!(list[Label3], labeled(Label3, true)); assert_eq!(list.elem::<Label3>(), &labeled(Label3, true));
pub fn elem_mut<TargetL>(&mut self) -> &mut Self::Elem where
Self: LookupElemByLabelMut<TargetL>,
[src]
Self: LookupElemByLabelMut<TargetL>,
Returns a mutable reference the element labeled by a specific label.
This is equivalent to using index list[Label]
notation in a mutable context.
Note that the label itself cannot be changed via this method since labels in lhlist
are
type-level.
Example
use lhlist::labeled; new_label![Label1: u8]; new_label![Label2: i8]; new_label![Label3: bool]; let mut list = lhlist![ Label1 = 9, Label2 = -4, Label3 = true, ]; let value2 = list.elem_mut::<Label2>(); assert_eq!(value2, &mut labeled(Label2, -4)); *value2 = labeled(Label2, -9); assert_eq!(list, lhlist![ Label1 = 9, Label2 = -9, Label3 = true, ]);
pub fn value<'a, TargetL>(&'a self) -> &'a <Self::Elem as Value>::Output where
Self: LookupElemByLabel<TargetL>,
Self::Elem: 'a + Value,
[src]
Self: LookupElemByLabel<TargetL>,
Self::Elem: 'a + Value,
Returns a reference the value (e.g. the value portion of a LabeledValue) labeled by a specific label.
This is equivalent to using index list[Label]
notation, with the exception that value
also works for transient (non-'static
) types.
Example
new_label![Label1: u8]; new_label![Label2: i8]; new_label![Label3: bool]; let list = lhlist![ Label1 = 9, Label2 = -4, Label3 = true, ]; assert_eq!(list[Label1], 9); assert_eq!(list.value::<Label1>(), &9); assert_eq!(list[Label2], -4); assert_eq!(list.value::<Label2>(), &-4); assert_eq!(list[Label3], true); assert_eq!(list.value::<Label3>(), &true);
pub fn value_mut<'a, TargetL>(
&'a mut self
) -> &'a mut <Self::Elem as Value>::Output where
Self: LookupElemByLabelMut<TargetL>,
Self::Elem: 'a + Value,
[src]
&'a mut self
) -> &'a mut <Self::Elem as Value>::Output where
Self: LookupElemByLabelMut<TargetL>,
Self::Elem: 'a + Value,
Returns a mutable reference the value (e.g. the value portion of a LabeledValue) labeled by a specific label.
This is equivalent to using index list[Label]
notation in mut
contexts, with the
exception that value_mut
also works for transient (non-'static
) types.
Example
new_label![Label1: u8]; new_label![Label2: i8]; new_label![Label3: bool]; let mut list = lhlist![ Label1 = 9, Label2 = -4, Label3 = true, ]; let value2 = list.value_mut::<Label2>(); assert_eq!(value2, &mut -4); *value2 = -9; assert_eq!(list, lhlist![ Label1 = 9, Label2 = -9, Label3 = true, ]); list[Label3] = false; assert_eq!(list, lhlist![ Label1 = 9, Label2 = -9, Label3 = false, ]);
Trait Implementations
impl<H, T> Len for Cons<H, T> where
T: Len,
[src]
T: Len,
impl<Lbl: Sized, Tail> StrLabels for Cons<Lbl, Tail> where
Self: Len + BuildStrLabels,
[src]
Self: Len + BuildStrLabels,
fn static_labels() -> Vec<&'static str>
[src]
fn labels(&self) -> Vec<&'static str>
[src]
Generates the label name Vec
using a value
impl<TargetL, L, T> Member<TargetL> for Cons<L, T> where
L: Label + LabelEq<TargetL>,
Self: MemberMatch<TargetL, <L as LabelEq<TargetL>>::Output>,
[src]
L: Label + LabelEq<TargetL>,
Self: MemberMatch<TargetL, <L as LabelEq<TargetL>>::Output>,
type Output = Self::Output
True if TargetL
is a member, False otherwise.
impl<TargetL, L, T> LookupElemByLabel<TargetL> for Cons<L, T> where
L: Label + LabelEq<TargetL>,
T: Member<TargetL>,
Self: LookupElemByLabelMatch<TargetL, <L as LabelEq<TargetL>>::Output, <T as Member<TargetL>>::Output>,
[src]
L: Label + LabelEq<TargetL>,
T: Member<TargetL>,
Self: LookupElemByLabelMatch<TargetL, <L as LabelEq<TargetL>>::Output, <T as Member<TargetL>>::Output>,
impl<T, Head, Tail> Adapter<T> for Cons<Head, Tail> where
Tail: Adapter<T>,
Head: Adapter<<Tail as Adapter<T>>::Output>,
[src]
Tail: Adapter<T>,
Head: Adapter<<Tail as Adapter<T>>::Output>,
type Output = <Head as Adapter<<Tail as Adapter<T>>::Output>>::Output
Transformation output type
fn adapt(&mut self, input: T) -> 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, TargetL, TargetT, A, L, T> CollectIntoLabeledHList<Cons<PhantomData<TargetL>, TargetT>> for ValuesIterator<'a, LVCons<L, T>, A> where
L: Label,
TargetL: Label,
A: Adapter<&'a L::AssocType, Output = TargetL::AssocType>,
ValuesIterator<'a, T, A>: CollectIntoLabeledHList<TargetT>,
[src]
L: Label,
TargetL: Label,
A: Adapter<&'a L::AssocType, Output = TargetL::AssocType>,
ValuesIterator<'a, T, A>: CollectIntoLabeledHList<TargetT>,
type Output = LVCons<TargetL, <ValuesIterator<'a, T, A> as CollectIntoLabeledHList<TargetT>>::Output>
Output type of collected list
fn collect_into_labeled_hlist(self) -> Self::Output
[src]
impl<H: Eq, T: Eq> Eq for Cons<H, T>
[src]
impl<H: Clone, T: Clone> Clone for Cons<H, T>
[src]
fn clone(&self) -> Cons<H, T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<H: PartialEq, T: PartialEq> PartialEq<Cons<H, T>> for Cons<H, T>
[src]
impl<H: Debug, T: Debug> Debug for Cons<H, T>
[src]
impl<L, H, T> Index<L> for Cons<H, T> where
Cons<H, T>: LookupElemByLabel<L>,
<Cons<H, T> as LookupElemByLabel<L>>::Elem: 'static + Value,
[src]
Cons<H, T>: LookupElemByLabel<L>,
<Cons<H, T> as LookupElemByLabel<L>>::Elem: 'static + Value,
type Output = <<Cons<H, T> as LookupElemByLabel<L>>::Elem as Value>::Output
The returned type after indexing.
fn index(&self, _index: L) -> &Self::Output
[src]
impl<L, H, T> IndexMut<L> for Cons<H, T> where
Cons<H, T>: LookupElemByLabelMut<L>,
<Cons<H, T> as LookupElemByLabel<L>>::Elem: 'static + Value,
[src]
Cons<H, T>: LookupElemByLabelMut<L>,
<Cons<H, T> as LookupElemByLabel<L>>::Elem: 'static + Value,
impl<H: Hash, T: Hash> Hash for Cons<H, T>
[src]
Auto Trait Implementations
impl<H, T> Send for Cons<H, T> where
H: Send,
T: Send,
H: Send,
T: Send,
impl<H, T> Sync for Cons<H, T> where
H: Sync,
T: Sync,
H: Sync,
T: Sync,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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