rust/tests/ui/traits/kindck-owned-contains-1.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
443 B
Rust
Raw Normal View History

// run-pass
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
trait repeat<A> { fn get(&self) -> A; }
impl<A:Clone + 'static> repeat<A> for Box<A> {
2013-07-02 19:47:32 +00:00
fn get(&self) -> A {
(**self).clone()
}
}
2019-05-28 18:47:21 +00:00
fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
Box::new(v) as Box<dyn repeat<A>+'static> // No
}
pub fn main() {
2015-01-25 21:05:03 +00:00
let x = 3;
let y = repeater(Box::new(x));
assert_eq!(x, y.get());
}