SHARE
TWEET

Untitled

a guest Aug 17th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::rc::Rc;
  2.  
  3. fn main() {
  4.     let add1: Rc<dyn Fn(i32, i32) -> i32> = Rc::new(|a, b| a + b);
  5.     let add2 = Rc::clone(&add1);
  6.  
  7.     let res = call_f(&*add2, 1, 2);
  8.     dbg!(res);
  9. }
  10.  
  11. fn call_f(f: &dyn Fn(i32, i32) -> i32, a: i32, b: i32) -> i32 {
  12.     f(a, b)
  13. }
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