rust/src/test/run-pass/issues/issue-3794.rs

33 lines
393 B
Rust
Raw Normal View History

// run-pass
#![feature(box_syntax)]
2012-12-06 20:32:13 -06:00
trait T {
fn print(&self);
}
2015-01-28 07:34:18 -06:00
#[derive(Debug)]
2012-12-06 20:32:13 -06:00
struct S {
s: isize,
2012-12-06 20:32:13 -06:00
}
impl T for S {
2012-12-06 20:32:13 -06:00
fn print(&self) {
println!("{:?}", self);
2012-12-06 20:32:13 -06:00
}
}
fn print_t(t: &T) {
t.print();
}
fn print_s(s: &S) {
s.print();
}
pub fn main() {
let s: Box<S> = box S { s: 5 };
print_s(&*s);
let t: Box<T> = s as Box<T>;
print_t(&*t);
2012-12-06 20:32:13 -06:00
}