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.
11 #![feature(arbitrary_self_types)]
13 #![feature(rustc_attrs)]
22 fn by_rc(self: Rc<Self>) -> i64;
23 fn by_arc(self: Arc<Self>) -> i64;
24 fn by_pin_mut(self: Pin<&mut Self>) -> i64;
25 fn by_pin_box(self: Pin<Box<Self>>) -> i64;
29 fn by_rc(self: Rc<Self>) -> i64 {
32 fn by_arc(self: Arc<Self>) -> i64 {
35 fn by_pin_mut(self: Pin<&mut Self>) -> i64 {
38 fn by_pin_box(self: Pin<Box<Self>>) -> i64 {
44 let rc = Rc::new(1i64) as Rc<dyn Trait>;
45 assert_eq!(1, rc.by_rc());
47 let arc = Arc::new(2i64) as Arc<dyn Trait>;
48 assert_eq!(2, arc.by_arc());
51 let pin_mut = Pin::new(&mut value) as Pin<&mut dyn Trait>;
52 assert_eq!(3, pin_mut.by_pin_mut());
54 let pin_box = Into::<Pin<Box<i64>>>::into(Box::new(4i64)) as Pin<Box<dyn Trait>>;
55 assert_eq!(4, pin_box.by_pin_box());