SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Stuc {
  2.     id: usize,
  3. }
  4.  
  5. impl Stuc {
  6.     fn fun(self) -> Box<Fn()> {
  7.         Box::new(move ||{
  8.             println!("id={}", self.id);
  9.         })
  10.     }
  11. }
  12.  
  13. fn main() {
  14.     let stuc = Stuc { id: 5 };
  15.     let fun = stuc.fun();
  16.     fun();
  17. }
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