rust/tests/ui/generics/generic-object.rs

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

22 lines
277 B
Rust
Raw Normal View History

// 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 });
2019-05-28 13:47:21 -05:00
let y = x as Box<dyn Foo<isize>>;
assert_eq!(y.get(), 1);
}