rust/tests/ui/no-reuse-move-arc.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
307 B
Rust
Raw Normal View History

use std::sync::Arc;
2015-02-17 23:10:25 +00:00
use std::thread;
fn main() {
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = Arc::new(v);
2012-05-24 20:35:57 +00:00
2015-02-17 23:10:25 +00:00
thread::spawn(move|| {
assert_eq!((*arc_v)[3], 4);
2014-01-27 23:29:50 +00:00
});
assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v`
println!("{:?}", *arc_v);
}