]> git.proxmox.com Git - rustc.git/blob - tests/ui/traits/kindck-owned-contains-1.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / traits / kindck-owned-contains-1.rs
1 // run-pass
2 #![allow(non_snake_case)]
3 #![allow(non_camel_case_types)]
4
5 trait repeat<A> { fn get(&self) -> A; }
6
7 impl<A:Clone + 'static> repeat<A> for Box<A> {
8 fn get(&self) -> A {
9 (**self).clone()
10 }
11 }
12
13 fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
14 Box::new(v) as Box<dyn repeat<A>+'static> // No
15 }
16
17 pub fn main() {
18 let x = 3;
19 let y = repeater(Box::new(x));
20 assert_eq!(x, y.get());
21 }