Frunk provides developers with a number of functional programming tools like HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid, Semigroup and friends.
#![feature(test)]externcrate frunk;externcrate test;usefrunk::semigroup::*;usetest::Bencher;#[bench]fncombine_i32(b:&mut Bencher){let x:i32=10;let y:i32=50;
b.iter(||x.combine(&y))}#[bench]fnstd_add_i32(b:&mut Bencher){let x:i32=10;let y:i32=50;
b.iter(||x + y)}#[bench]fncombine_option_string(b:&mut Bencher){let x:Option<String>=Some("hello".to_owned());let y:Option<String>=Some(" world".to_owned());
b.iter(||x.combine(&y))}#[bench]fnstd_add_option_string(b:&mut Bencher){let x:Option<String>=Some("hello".to_owned());let y:Option<String>=Some(" world".to_owned());
b.iter(||{// cloning is required otherwise we get `cannot move out of captured outer variable in an `FnMut` closure` errors
let a = x.clone();let b = y.clone();
a.and_then(|first|b.map(|second|first +&second))})}