2014-06-07 11:13:26 -07:00
|
|
|
use std::sync::Arc;
|
2015-02-17 15:10:25 -08:00
|
|
|
use std::thread;
|
2013-05-24 19:35:29 -07:00
|
|
|
|
2012-05-23 15:46:43 -07:00
|
|
|
fn main() {
|
2016-10-29 22:54:04 +01:00
|
|
|
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
2014-01-30 15:04:47 -05:00
|
|
|
let arc_v = Arc::new(v);
|
2012-05-24 13:35:57 -07:00
|
|
|
|
2015-02-17 15:10:25 -08:00
|
|
|
thread::spawn(move|| {
|
2014-10-14 23:05:01 -07:00
|
|
|
assert_eq!((*arc_v)[3], 4);
|
2014-01-27 18:29:50 -05:00
|
|
|
});
|
2012-05-23 15:46:43 -07:00
|
|
|
|
2019-04-22 08:40:08 +01:00
|
|
|
assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v`
|
2012-05-23 15:46:43 -07:00
|
|
|
|
2019-04-22 08:40:08 +01:00
|
|
|
println!("{:?}", *arc_v);
|
2012-05-23 15:46:43 -07:00
|
|
|
}
|