1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use std::rc::{Rc, Weak};
17 let mut a = Weak::<Void>::new();
19 assert!(a.upgrade().is_none());
21 let mut a: Weak<dyn Any> = a; // Unsizing
23 assert!(a.upgrade().is_none());
28 let a: Rc<[u32; 3]> = Rc::new([3, 2, 1]);
29 let a: Rc<[u32]> = a; // Unsizing
30 let b: Rc<[u32]> = Rc::from(&[3, 2, 1][..]); // Conversion
33 // Exercise is_dangling() with a DST
34 let mut a = Rc::downgrade(&a);
36 assert!(a.upgrade().is_some());
41 let a: Rc<u32> = Rc::new(4);
42 let a: Rc<dyn Any> = a; // Unsizing
44 // Exercise is_dangling() with a DST
45 let mut a = Rc::downgrade(&a);
47 assert!(a.upgrade().is_some());
49 let mut b = Weak::<u32>::new();
51 assert!(b.upgrade().is_none());
52 let mut b: Weak<dyn Any> = b; // Unsizing
54 assert!(b.upgrade().is_none());