Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn compose<P,R0,R1,F0,F1,FR>(mut f0:F0,mut f1:F1)->FR
- where
- F0:FnMut(P)->R0,
- F1:FnMut(R0)->R1,
- FR:FnMut(P)->R1,
- {
- move|x|{
- let x=f0(x);
- f1(x)
- }
- }
- fn main(){
- let mut func=compose(|x|x+2,|x|x*2);
- assert_eq!(4,func(0));
- assert_eq!(6,func(1));
- assert_eq!(8,func(2));
- }
Add Comment
Please, Sign In to add comment