SHARE
TWEET

Untitled

a guest Aug 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let mut one = 1;
  3.     let plus_one = |x| {
  4.         x + one
  5.     };
  6.     let b = plus_one(10);
  7.     one += 1; // まだ参照が生きてるからこれはOK
  8.     let c = plus_one(10); // ここでplus_oneが必要なのでまだ死ねない
  9.     assert_eq!(b, 11);
  10.     assert_eq!(one, 2);
  11. }
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