Non-working example on how to fix ownership
This commit is contained in:
parent
14e7c08152
commit
11597fa330
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "rcrefcell"
|
||||
version = "0.1.0"
|
24
src/bin/notworking.rs
Normal file
24
src/bin/notworking.rs
Normal file
@ -0,0 +1,24 @@
|
||||
fn c<F: FnOnce() + 'static>(f: F) {
|
||||
f();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v = vec![1, 2, 3];
|
||||
|
||||
c({
|
||||
let mut v = v.clone();
|
||||
move || {
|
||||
println!("inner 1: {:?}", v);
|
||||
v.push(4);
|
||||
}
|
||||
});
|
||||
c({
|
||||
let mut v = v.clone();
|
||||
move || {
|
||||
println!("inner 2: {:?}", v);
|
||||
v.push(5);
|
||||
}
|
||||
});
|
||||
|
||||
println!("outer: {:?}", v);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user