Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::ops::Add;
- fn f1<T>(a: T, b: T) -> impl Fn(T) -> T
- where T: Add<Output=T> + Copy,
- {
- move |c| c + a + b
- }
- fn f2<T>(f: impl Fn(T) -> T, val: T) -> T
- where T: Add<Output=T> + Copy,
- {
- f(val)
- }
- fn main() {
- let r = f1(2.0, 3.0)(4.3);
- let r = f2(|x| x + 1, 3);
- println!("res: {:?}", r);
- }
Add Comment
Please, Sign In to add comment