Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let mutating_closure1 = |x: &mut i32| { *x += 1; };
- // The closure is Copy, even though it takes a &mut argument!
- let mutating_closure2 = mutating_closure1;
- let mut x = 5;
- mutating_closure1(&mut x);
- mutating_closure2(&mut x);
- dbg!(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement