mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
22 lines
278 B
Rust
22 lines
278 B
Rust
//@ 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);
|
|
}
|