2024-02-16 20:02:50 +00:00
|
|
|
//@ error-pattern: borrow of moved value
|
2012-05-23 22:46:43 +00:00
|
|
|
|
2014-06-07 18:13:26 +00:00
|
|
|
use std::sync::Arc;
|
2015-02-17 23:10:25 +00:00
|
|
|
use std::thread;
|
2013-05-25 02:35:29 +00:00
|
|
|
|
2012-05-23 22:46:43 +00:00
|
|
|
fn main() {
|
2016-10-29 21:54:04 +00:00
|
|
|
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
2014-01-30 20:04:47 +00:00
|
|
|
let arc_v = Arc::new(v);
|
2013-05-03 23:25:04 +00:00
|
|
|
|
2015-02-17 23:10:25 +00:00
|
|
|
thread::spawn(move|| {
|
2014-10-15 06:05:01 +00:00
|
|
|
assert_eq!((*arc_v)[3], 4);
|
2014-01-27 23:29:50 +00:00
|
|
|
});
|
2012-05-23 22:46:43 +00:00
|
|
|
|
2014-10-15 06:05:01 +00:00
|
|
|
assert_eq!((*arc_v)[2], 3);
|
2012-05-23 22:46:43 +00:00
|
|
|
|
2015-01-07 22:58:31 +00:00
|
|
|
println!("{:?}", *arc_v);
|
2012-05-23 22:46:43 +00:00
|
|
|
}
|