1 // Copyright 2015 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.
11 // Test a very simple custom DST coercion.
13 #![feature(core, rc_weak)]
15 use std::cell::RefCell;
16 use std::rc::{Rc, Weak};
23 fn get(&self) -> i32 {
29 let a: Rc<[i32; 3]> = Rc::new([1, 2, 3]);
35 let a: Rc<i32> = Rc::new(42);
36 let b: Rc<Baz> = a.clone();
37 assert_eq!(b.get(), 42);
39 let c: Weak<i32> = Rc::downgrade(&a);
40 let d: Weak<Baz> = c.clone();
44 let a: Rc<RefCell<i32>> = Rc::new(RefCell::new(42));
45 let b: Rc<RefCell<Baz>> = a.clone();
46 assert_eq!(b.borrow().get(), 42);
48 let c: Weak<RefCell<Baz>> = Rc::downgrade(&a) as Weak<_>;