Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn compose<X, Y, Z>(a: Box<Fn(Y) -> Z>, b: Box<Fn(X) -> Y>) -> Box<Fn(X) -> Z>
- where X: 'static,
- Y: 'static,
- Z: 'static
- {
- Box::new(move |c| a(b(c)))
- }
- fn main() {
- let composed = compose(Box::new(move |num| num - 1), Box::new(move |num| num * 2));
- println!("{}", composed(10));
- //=> 19
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement