mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
22 lines
508 B
Rust
22 lines
508 B
Rust
//@ run-pass
|
|
#![allow(incomplete_features)]
|
|
#![feature(move_expr)]
|
|
|
|
use std::sync::Arc;
|
|
|
|
fn main() {
|
|
let v = Arc::new("Hello, Ferris".to_string());
|
|
let outer = || || (move(move(v.clone()))).len();
|
|
|
|
assert_eq!(Arc::strong_count(&v), 2);
|
|
let inner = outer();
|
|
assert_eq!(Arc::strong_count(&v), 2);
|
|
assert_eq!(inner(), v.len());
|
|
assert_eq!(inner(), v.len());
|
|
assert_eq!(Arc::strong_count(&v), 2);
|
|
drop(inner);
|
|
assert_eq!(Arc::strong_count(&v), 1);
|
|
|
|
println!("{v}");
|
|
}
|