A grab-bag of useful functions for functional programming.
rust
extern crate tool;
use tool::prelude::*;
fn main() {
let strings: Vec<_> = vec!["my string", "", "asdf", ""]
.into_iter()
.filter(non_empty)
.collect();
assert_eq!(strings, vec!["my string", "asdf"]);
}
```rust extern crate tool; use tool::prelude::*; fn main() { let strings: Vec<_> = vec![("first", 1), ("second", 2), ("third", 3), ("fourth", 4)] .into_iter() .map(first) .collect();
assert_eq!(strings, vec!["first", "second", "third", "fourth"]);
} ```
use_std
(default: enabled) - Disable this if you're project doesn't depend on libstd.unstable
(default: disabled) - Enable this if you are targeting nightly and
want to be able to use the latest unstable features.Currently, the following features are unstable:
functor
module. Functors require the impl Trait
feature so this module
will stabilize when conservative_impl_trait
stabilizes.