SHARE
TWEET

Untitled

a guest Dec 16th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::ops::Add;
  2.  
  3.  
  4. fn f1<T>(a: T, b: T) -> impl Fn(T) -> T
  5. where T: Add<Output=T> + Copy,
  6. {
  7.     move |c| c + a + b
  8. }
  9.  
  10.  
  11. fn f2<T>(f: impl Fn(T) -> T, val: T) -> T
  12. where T: Add<Output=T> + Copy,
  13. {
  14.    
  15.     f(val)
  16. }
  17.  
  18.  
  19.  
  20. fn main() {
  21.    
  22.     let r = f1(2.0, 3.0)(4.3);
  23.    
  24.     let r = f2(|x| x + 1, 3);
  25.    
  26.     println!("res: {:?}", r);
  27.    
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top