[−][src]Struct wasm_reader_traits::hlist::HNil
Represents the right-most end of a heterogeneous list
Examples
let h = h_cons(1, HNil); let h = h.head; assert_eq!(h, 1);
Methods
impl HNil
[src]
pub fn len(&self) -> usize where
HNil: HList,
[src]
HNil: HList,
pub fn prepend<H>(self, h: H) -> HCons<H, HNil> where
HNil: HList,
[src]
HNil: HList,
Prepend an item to the current HList
Examples
let h1 = hlist![1, "hi"]; let h2 = h1.prepend(true); let (a, (b, c)) = h2.into_tuple2(); assert_eq!(a, true); assert_eq!(b, 1); assert_eq!(c, "hi");
pub fn sculpt<Ts, Indices>(
self
) -> (Ts, <HNil as Sculptor<Ts, Indices>>::Remainder) where
HNil: Sculptor<Ts, Indices>,
[src]
self
) -> (Ts, <HNil as Sculptor<Ts, Indices>>::Remainder) where
HNil: Sculptor<Ts, Indices>,
Consume the current HList and return an HList with the requested shape.
sculpt
allows us to extract/reshape/scult the current HList into another shape,
provided that the requested shape's types are are contained within the current HList.
The Indices
type parameter allows the compiler to figure out that Ts
and Self
can be morphed into each other.
Examples
let h = hlist![9000, "joe", 41f32, true]; let (reshaped, remainder): (Hlist![f32, i32, &str], _) = h.sculpt(); assert_eq!(reshaped, hlist![41f32, 9000, "joe"]); assert_eq!(remainder, hlist![true]);
pub fn into_reverse(self) -> <HNil as IntoReverse>::Output where
HNil: IntoReverse,
[src]
HNil: IntoReverse,
Reverse the HList.
Examples
assert_eq!(hlist![].into_reverse(), hlist![]); assert_eq!( hlist![1, "hello", true, 42f32].into_reverse(), hlist![42f32, true, "hello", 1], )
pub fn to_ref<'a>(&'a self) -> <HNil as ToRef<'a>>::Output where
HNil: ToRef<'a>,
[src]
HNil: ToRef<'a>,
Return an HList where the contents are references to the original HList on which this method was called.
Examples
assert_eq!(hlist![].to_ref(), hlist![]); assert_eq!(hlist![1, true].to_ref(), hlist![&1, &true]);
pub fn to_mut<'a>(&'a mut self) -> <HNil as ToMut<'a>>::Output where
HNil: ToMut<'a>,
[src]
HNil: ToMut<'a>,
Return an HList
where the contents are mutable references
to the original HList
on which this method was called.
Examples
assert_eq!(hlist![].to_mut(), hlist![]); assert_eq!(hlist![1, true].to_mut(), hlist![&mut 1, &mut true]);
pub fn map<F>(self, mapper: F) -> <HNil as HMappable<F>>::Output where
HNil: HMappable<F>,
[src]
HNil: HMappable<F>,
Apply a function to each element of an HList.
This transforms some Hlist![A, B, C, ..., E]
into some
Hlist![T, U, V, ..., Z]
. A variety of types are supported
for the folder argument:
- An
hlist![]
of closures (one for each element). - A single closure (for mapping an HList that is homogenous).
- A single
Poly
.
Examples
use ::frunk::HNil; assert_eq!(HNil.map(HNil), HNil); let h = hlist![1, false, 42f32]; // Sadly we need to help the compiler understand the bool type in our mapper let mapped = h.to_ref().map(hlist![ |&n| n + 1, |b: &bool| !b, |&f| f + 1f32]); assert_eq!(mapped, hlist![2, true, 43f32]); // There is also a value-consuming version that passes values to your functions // instead of just references: let mapped2 = h.map(hlist![ |n| n + 3, |b: bool| !b, |f| f + 8959f32]); assert_eq!(mapped2, hlist![4, true, 9001f32]);
pub fn zip<Other>(self, other: Other) -> <HNil as HZippable<Other>>::Zipped where
HNil: HZippable<Other>,
[src]
HNil: HZippable<Other>,
Zip two HLists together.
This zips a Hlist![A1, B1, ..., C1]
with a Hlist![A2, B2, ..., C2]
to make a Hlist![(A1, A2), (B1, B2), ..., (C1, C2)]
Example
use ::frunk::HNil; assert_eq!(HNil.zip(HNil), HNil); let h1 = hlist![1, false, 42f32]; let h2 = hlist![true, "foo", 2]; let zipped = h1.zip(h2); assert_eq!(zipped, hlist![ (1, true), (false, "foo"), (42f32, 2), ]);
pub fn foldl<Folder, Acc>(
self,
folder: Folder,
acc: Acc
) -> <HNil as HFoldLeftable<Folder, Acc>>::Output where
HNil: HFoldLeftable<Folder, Acc>,
[src]
self,
folder: Folder,
acc: Acc
) -> <HNil as HFoldLeftable<Folder, Acc>>::Output where
HNil: HFoldLeftable<Folder, Acc>,
Perform a left fold over an HList.
This transforms some Hlist![A, B, C, ..., E]
into a single
value by visiting all of the elements in left-to-right order.
A variety of types are supported for the mapper argument:
- An
hlist![]
of closures (one for each element). - A single closure (for folding an HList that is homogenous).
The accumulator can freely change type over the course of the call.
When called with a list of N
functions, an expanded form of the
implementation with type annotations might look something like this:
let acc: Acc0 = init_value; let acc: Acc1 = f1(acc, x1); let acc: Acc2 = f2(acc, x2); let acc: Acc3 = f3(acc, x3); ... let acc: AccN = fN(acc, xN); acc
Examples
let nil = hlist![]; assert_eq!(nil.foldl(hlist![], 0), 0); let h = hlist![1, false, 42f32]; let folded = h.to_ref().foldl( hlist![ |acc, &i| i + acc, |acc, b: &bool| if !b && acc > 42 { 9000f32 } else { 0f32 }, |acc, &f| f + acc ], 1 ); assert_eq!(42f32, folded); // There is also a value-consuming version that passes values to your folding // functions instead of just references: let folded2 = h.foldl( hlist![ |acc, i| i + acc, |acc, b: bool| if !b && acc > 42 { 9000f32 } else { 0f32 }, |acc, f| f + acc ], 8918 ); assert_eq!(9042f32, folded2)
pub fn foldr<Folder, Init>(
self,
folder: Folder,
init: Init
) -> <HNil as HFoldRightable<Folder, Init>>::Output where
HNil: HFoldRightable<Folder, Init>,
[src]
self,
folder: Folder,
init: Init
) -> <HNil as HFoldRightable<Folder, Init>>::Output where
HNil: HFoldRightable<Folder, Init>,
Perform a right fold over an HList.
This transforms some Hlist![A, B, C, ..., E]
into a single
value by visiting all of the elements in reverse order.
A variety of types are supported for the mapper argument:
- An
hlist![]
of closures (one for each element). - A single closure (for folding an HList that is homogenous), taken by reference.
The accumulator can freely change type over the course of the call.
Comparison to foldl
While the order of element traversal in foldl
may seem more natural,
foldr
does have its use cases, in particular when it is used to build
something that reflects the structure of the original HList (such as
folding an HList of Option
s into an Option
of an HList).
An implementation of such a function using foldl
will tend to
reverse the list, while foldr
will tend to preserve its order.
The reason for this is because foldr
performs what is known as
"structural induction;" it can be understood as follows:
- Write out the HList in terms of
h_cons
andHNil
. - Substitute each
h_cons
with a function, and substituteHNil
withinit
the list: h_cons(x1, h_cons(x2, h_cons(x3, ...h_cons(xN, HNil))...))) becomes: f1( x1, f2( x2, f3( x3, ... fN( xN, init))...)))
Examples
let nil = hlist![]; assert_eq!(nil.foldr(hlist![], 0), 0); let h = hlist![1, false, 42f32]; let folded = h.foldr( hlist![ |i, acc| i + acc, |b: bool, acc| if !b && acc > 42f32 { 9000 } else { 0 }, |f, acc| f + acc ], 1f32 ); assert_eq!(9001, folded)
Trait Implementations
impl<RHS> Add<RHS> for HNil where
RHS: HList,
[src]
RHS: HList,
type Output = RHS
The resulting type after applying the +
operator.
fn add(self, rhs: RHS) -> RHS
[src]
impl Clone for HNil
[src]
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl Copy for HNil
[src]
impl Debug for HNil
[src]
impl Default for HNil
[src]
impl Eq for HNil
[src]
impl From<()> for HNil
[src]
impl<F, Acc> HFoldLeftable<F, Acc> for HNil
[src]
impl<F, Init> HFoldRightable<F, Init> for HNil
[src]
impl HList for HNil
[src]
const LEN: usize
[src]
fn static_len() -> usize
[src]
fn length(&self) -> u32
[src]
fn len(&self) -> usize
[src]
fn prepend<H>(self, h: H) -> HCons<H, Self>
[src]
impl<F> HMappable<F> for HNil
[src]
impl HZippable<HNil> for HNil
[src]
impl Hash for HNil
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Into<Vec<T>> for HNil
[src]
impl IntoReverse for HNil
[src]
type Output = HNil
fn into_reverse(self) -> <HNil as IntoReverse>::Output
[src]
impl IntoUnlabelled for HNil
[src]
Implementation for HNil
type Output = HNil
fn into_unlabelled(self) -> <HNil as IntoUnlabelled>::Output
[src]
impl IntoValueLabelled for HNil
[src]
type Output = HNil
fn into_value_labelled(self) -> <HNil as IntoValueLabelled>::Output
[src]
impl Ord for HNil
[src]
fn cmp(&self, other: &HNil) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<HNil> for HNil
[src]
impl PartialOrd<HNil> for HNil
[src]
fn partial_cmp(&self, other: &HNil) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
Implementation for when the target is an empty HList (HNil)
Index type is HNil because we don't need an index for finding HNil
impl StructuralEq for HNil
[src]
impl StructuralPartialEq for HNil
[src]
impl<'a> ToMut<'a> for HNil
[src]
impl<'a> ToRef<'a> for HNil
[src]
impl Transmogrifier<HNil, HNil> for HNil
[src]
Implementation of Transmogrifier
for when the Target
is empty and the Source
is empty.
fn transmogrify(self) -> HNil
[src]
impl<SourceHead, SourceTail> Transmogrifier<HNil, HNil> for HCons<SourceHead, SourceTail>
[src]
Implementation of Transmogrifier
for when the Target
is empty and the Source
is non-empty.
fn transmogrify(self) -> HNil
[src]
Auto Trait Implementations
impl RefUnwindSafe for HNil
impl Send for HNil
impl Sync for HNil
impl Unpin for HNil
impl UnwindSafe for HNil
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
[src]
type Remainder = Choices
fn subset(
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
[src]
self
) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U, I> LiftInto<U, I> for T where
U: LiftFrom<T, I>,
[src]
U: LiftFrom<T, I>,
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
impl<Source> Sculptor<HNil, HNil> for Source
[src]
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> 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>,