summaryrefslogtreecommitdiffstats
path: root/tests/ui/generics/generic-object.rs
blob: 851424a11b5c141c31014ad91499928511091fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass

trait Foo<T> {
    fn get(&self) -> T;
}

struct S {
    x: isize
}

impl Foo<isize> for S {
    fn get(&self) -> isize {
        self.x
    }
}

pub fn main() {
    let x = Box::new(S { x: 1 });
    let y = x as Box<dyn Foo<isize>>;
    assert_eq!(y.get(), 1);
}