pub struct Cons<Head, Tail>(pub Head, pub Tail)
where
Tail: ?Sized;Expand description
Heterogenous list with head and tail values, where tail is another heterogenous list.
Tuple Fields§
§0: Head§1: TailImplementations§
Source§impl<Head, Tail> Cons<Head, Tail>
impl<Head, Tail> Cons<Head, Tail>
Source§impl<Head, Tail> Cons<Head, Tail>where
Tail: ?Sized,
impl<Head, Tail> Cons<Head, Tail>where
Tail: ?Sized,
Sourcepub const fn head(&self) -> &Head
pub const fn head(&self) -> &Head
Borrows head value of self by reference.
§Examples
use hlist2::Cons;
let list = Cons::new(1, "hello world");
let head = list.head();
assert_eq!(head, &1);Sourcepub fn head_mut(&mut self) -> &mut Head
pub fn head_mut(&mut self) -> &mut Head
Borrows head value of self by mutable reference.
§Examples
use hlist2::Cons;
let mut list = Cons::new(1, "hello world");
let head = list.head_mut();
*head = 2;
assert_eq!(list, Cons(2, "hello world"));Trait Implementations§
Source§impl<A, B, C, D> From<(A, B, C, D)> for Cons<A, Cons<B, Cons<C, Cons<D, Nil>>>>
impl<A, B, C, D> From<(A, B, C, D)> for Cons<A, Cons<B, Cons<C, Cons<D, Nil>>>>
Source§fn from(value: (A, B, C, D)) -> Self
fn from(value: (A, B, C, D)) -> Self
Source§impl<A, B, C, D, E> From<(A, B, C, D, E)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Nil>>>>>
impl<A, B, C, D, E> From<(A, B, C, D, E)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Nil>>>>>
Source§fn from(value: (A, B, C, D, E)) -> Self
fn from(value: (A, B, C, D, E)) -> Self
Source§impl<A, B, C, D, E, F> From<(A, B, C, D, E, F)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Nil>>>>>>
impl<A, B, C, D, E, F> From<(A, B, C, D, E, F)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Nil>>>>>>
Source§fn from(value: (A, B, C, D, E, F)) -> Self
fn from(value: (A, B, C, D, E, F)) -> Self
Source§impl<A, B, C, D, E, F, G> From<(A, B, C, D, E, F, G)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Nil>>>>>>>
impl<A, B, C, D, E, F, G> From<(A, B, C, D, E, F, G)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Nil>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G)) -> Self
fn from(value: (A, B, C, D, E, F, G)) -> Self
Source§impl<A, B, C, D, E, F, G, H> From<(A, B, C, D, E, F, G, H)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Nil>>>>>>>>
impl<A, B, C, D, E, F, G, H> From<(A, B, C, D, E, F, G, H)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Nil>>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G, H)) -> Self
fn from(value: (A, B, C, D, E, F, G, H)) -> Self
Source§impl<A, B, C, D, E, F, G, H, I> From<(A, B, C, D, E, F, G, H, I)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Nil>>>>>>>>>
impl<A, B, C, D, E, F, G, H, I> From<(A, B, C, D, E, F, G, H, I)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Nil>>>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G, H, I)) -> Self
fn from(value: (A, B, C, D, E, F, G, H, I)) -> Self
Source§impl<A, B, C, D, E, F, G, H, I, J> From<(A, B, C, D, E, F, G, H, I, J)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Nil>>>>>>>>>>
impl<A, B, C, D, E, F, G, H, I, J> From<(A, B, C, D, E, F, G, H, I, J)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Nil>>>>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G, H, I, J)) -> Self
fn from(value: (A, B, C, D, E, F, G, H, I, J)) -> Self
Source§impl<A, B, C, D, E, F, G, H, I, J, K> From<(A, B, C, D, E, F, G, H, I, J, K)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Nil>>>>>>>>>>>
impl<A, B, C, D, E, F, G, H, I, J, K> From<(A, B, C, D, E, F, G, H, I, J, K)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Nil>>>>>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G, H, I, J, K)) -> Self
fn from(value: (A, B, C, D, E, F, G, H, I, J, K)) -> Self
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L> From<(A, B, C, D, E, F, G, H, I, J, K, L)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Cons<L, Nil>>>>>>>>>>>>
impl<A, B, C, D, E, F, G, H, I, J, K, L> From<(A, B, C, D, E, F, G, H, I, J, K, L)> for Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Cons<L, Nil>>>>>>>>>>>>
Source§fn from(value: (A, B, C, D, E, F, G, H, I, J, K, L)) -> Self
fn from(value: (A, B, C, D, E, F, G, H, I, J, K, L)) -> Self
Source§impl<Head, Tail> From<(Head, Tail)> for Cons<Head, Tail>
impl<Head, Tail> From<(Head, Tail)> for Cons<Head, Tail>
Source§fn from(value: (Head, Tail)) -> Self
fn from(value: (Head, Tail)) -> Self
Source§impl<A, B, C, D, E, F, G, H, I, J, K, L> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Cons<L, Nil>>>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J, K, L)
impl<A, B, C, D, E, F, G, H, I, J, K, L> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Cons<L, Nil>>>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J, K, L)
Source§impl<A, B, C, D, E, F, G, H, I, J, K> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Nil>>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J, K)
impl<A, B, C, D, E, F, G, H, I, J, K> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Cons<K, Nil>>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J, K)
Source§impl<A, B, C, D, E, F, G, H, I, J> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Nil>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J)
impl<A, B, C, D, E, F, G, H, I, J> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Cons<J, Nil>>>>>>>>>>> for (A, B, C, D, E, F, G, H, I, J)
Source§impl<A, B, C, D, E, F, G, H, I> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Nil>>>>>>>>>> for (A, B, C, D, E, F, G, H, I)
impl<A, B, C, D, E, F, G, H, I> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Cons<I, Nil>>>>>>>>>> for (A, B, C, D, E, F, G, H, I)
Source§impl<A, B, C, D, E, F, G, H> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Nil>>>>>>>>> for (A, B, C, D, E, F, G, H)
impl<A, B, C, D, E, F, G, H> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Cons<H, Nil>>>>>>>>> for (A, B, C, D, E, F, G, H)
Source§impl<A, B, C, D, E, F, G> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Nil>>>>>>>> for (A, B, C, D, E, F, G)
impl<A, B, C, D, E, F, G> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Cons<G, Nil>>>>>>>> for (A, B, C, D, E, F, G)
Source§impl<A, B, C, D, E, F> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Nil>>>>>>> for (A, B, C, D, E, F)
impl<A, B, C, D, E, F> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Nil>>>>>>> for (A, B, C, D, E, F)
Source§impl<A, B, C, D, E> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Nil>>>>>> for (A, B, C, D, E)
impl<A, B, C, D, E> From<Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Nil>>>>>> for (A, B, C, D, E)
Source§impl<Head, Tail> From<Cons<Head, Tail>> for (Head, Tail)
impl<Head, Tail> From<Cons<Head, Tail>> for (Head, Tail)
Source§impl<Head, Tail> FromIterator<Head> for Cons<Head, Tail>where
Tail: FromIterator<Head>,
impl<Head, Tail> FromIterator<Head> for Cons<Head, Tail>where
Tail: FromIterator<Head>,
Source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Head>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = Head>,
Creates a new heterogenous list from an input iterator.
Iterator must contain the same count of elements as the target list type.
§Panics
This function will panic if there is not enough elements in the iterator or if there is no space for elements from the iterator.
§Examples
use hlist2::hlist;
let hlist!(a, b, c, d, e) = [42; 5].into_iter().collect();If iterator is too long, this call will panic:
use hlist2::hlist;
let hlist!(a, b, c, d, e) = [42; 10].into_iter().collect();If iterator is too short, this also will panic:
use hlist2::hlist;
let hlist!(a, b, c, d, e) = [42; 1].into_iter().collect();Source§impl<Head, Tail, FromTail, TailIndex> Get<FromTail, There<TailIndex>> for Cons<Head, Tail>
Desired type is located somewhere in the tail of the heterogenous list.
impl<Head, Tail, FromTail, TailIndex> Get<FromTail, There<TailIndex>> for Cons<Head, Tail>
Desired type is located somewhere in the tail of the heterogenous list.
Source§impl<Head, Tail> Get<Head, Here> for Cons<Head, Tail>
Desired type is located in the head of the heterogenous list.
impl<Head, Tail> Get<Head, Here> for Cons<Head, Tail>
Desired type is located in the head of the heterogenous list.
Source§impl<Head, Tail> Index<Here> for Cons<Head, Tail>
Retrieves the first element of the heterogenous list in immutable contexts.
impl<Head, Tail> Index<Here> for Cons<Head, Tail>
Retrieves the first element of the heterogenous list in immutable contexts.
§Examples
use hlist2::{hlist, ops::Here};
let list = hlist![1, 2.0, false];
let a = list[Here];
assert_eq!(a, 1);Source§impl<Head, Tail, TailIndex> Index<There<TailIndex>> for Cons<Head, Tail>
Performs indexing operation in the tail
of the heterogenous list in immutable contexts.
impl<Head, Tail, TailIndex> Index<There<TailIndex>> for Cons<Head, Tail>
Performs indexing operation in the tail of the heterogenous list in immutable contexts.
§Examples
use hlist2::{hlist, ops::{Here, Inc}};
let list = hlist![1, 2.0, false];
let index = Here.inc();
assert_eq!(list[index], 2.0);
let index = index.inc();
assert_eq!(list[index], false);Source§impl<Head, Tail> IndexMut<Here> for Cons<Head, Tail>
Retrieves the first element of the heterogenous list in mutable contexts.
impl<Head, Tail> IndexMut<Here> for Cons<Head, Tail>
Retrieves the first element of the heterogenous list in mutable contexts.
§Examples
use hlist2::{hlist, ops::Here};
let mut list = hlist![1, 2.0, false];
list[Here] = 5;
let a = list[Here];
assert_eq!(a, 5);Source§impl<Head, Tail, TailIndex> IndexMut<There<TailIndex>> for Cons<Head, Tail>
Performs indexing operation in the tail
of the heterogenous list in mutable contexts.
impl<Head, Tail, TailIndex> IndexMut<There<TailIndex>> for Cons<Head, Tail>
Performs indexing operation in the tail of the heterogenous list in mutable contexts.
§Examples
use hlist2::{hlist, ops::{Here, Inc}};
let mut list = hlist![1, 2.0, false];
let index = Here.inc();
list[index] = 16_f32.sqrt();
let b = list[index];
assert_eq!(b, 4.0);