pub trait Foldable<I, F> {
// Required method
fn fold(self, init: I, f: F) -> I;
}Expand description
Foldable heterogenous list
§Example
#![cfg_attr(feature="nightly", feature(unsize, fn_traits, unboxed_closures))]
#[macro_use]
extern crate hetseq;
use hetseq::{Foldable, Functor, Queue};
#[cfg(not(feature="nightly"))]
use hetseq::prelude::*;
use std::fmt::Display;
lambda![ let Formatter = |arg: Display| -> String { format!("{}", arg) } ];
lambda![
let Extender = |item, extend: Extend<item>| -> extend {
extend.extend(::std::iter::once(item));
extend
}
];
fn main() {
let queue = hqueue![1, 2.5];
let strings = queue.fmap(&Formatter).fold(Vec::new(), &Extender);
assert_eq!(strings, ["1", "2.5"]);
}