Get

Trait Get 

Source
pub trait Get<T, I>: HList
where I: Index,
{ // Required methods fn get(&self) -> &T; fn get_mut(&mut self) -> &mut T; }
Expand description

Retrieve element of the heterogenous list by type.

Required Methods§

Source

fn get(&self) -> &T

Retrieves a reference to the element of the heterogenous list by type.

§Examples
use hlist2::{hlist, ops::Get};

let list = hlist![0_i32, 1_i64];
let a: i64 = *list.get();
assert_eq!(a, 1);
Source

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

Retrieves a mutable reference to the element of the heterogenous list by type.

§Examples
use hlist2::{hlist, ops::Get};

let mut list = hlist![0_i32, 1_i64];
*list.get_mut() = 5_i32;
let a: i32 = *list.get();
assert_eq!(a, 5);

Implementors§

Source§

impl<Head, Tail> Get<Head, Here> for Cons<Head, Tail>
where Tail: HList + ?Sized,

Desired type is located in the head of the heterogenous list.

Source§

impl<Head, Tail, FromTail, TailIndex> Get<FromTail, There<TailIndex>> for Cons<Head, Tail>
where Tail: Get<FromTail, TailIndex> + ?Sized, TailIndex: Index,

Desired type is located somewhere in the tail of the heterogenous list.