2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2018-08-31 15:02:01 +02:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2015-01-08 02:25:56 +01:00
|
|
|
#![feature(box_syntax)]
|
2014-05-06 03:56:44 +02:00
|
|
|
|
2013-03-13 03:32:14 +01:00
|
|
|
trait repeat<A> { fn get(&self) -> A; }
|
2012-07-18 20:01:54 +02:00
|
|
|
|
2014-05-06 03:56:44 +02:00
|
|
|
impl<A:Clone + 'static> repeat<A> for Box<A> {
|
2013-07-02 21:47:32 +02:00
|
|
|
fn get(&self) -> A {
|
|
|
|
(**self).clone()
|
|
|
|
}
|
2012-07-18 20:01:54 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 20:47:21 +02:00
|
|
|
fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
|
|
|
|
box v as Box<dyn repeat<A>+'static> // No
|
2012-07-18 20:01:54 +02:00
|
|
|
}
|
|
|
|
|
2013-02-02 04:43:17 +01:00
|
|
|
pub fn main() {
|
2015-01-25 22:05:03 +01:00
|
|
|
let x = 3;
|
2014-05-06 03:56:44 +02:00
|
|
|
let y = repeater(box x);
|
2013-07-19 02:12:46 +02:00
|
|
|
assert_eq!(x, y.get());
|
2013-02-14 20:47:00 +01:00
|
|
|
}
|