Skip to content

Instantly share code, notes, and snippets.

@erickt
Created October 17, 2012 19:15
Show Gist options
  • Save erickt/3907509 to your computer and use it in GitHub Desktop.
Save erickt/3907509 to your computer and use it in GitHub Desktop.
test.rs:27:12: 27:13 error: mismatched types: expected `&/T` but found `@T` (trait storage differs: expected & but found @)
test.rs:27 print_t(t);
^
error: aborting due to previous error
trait T {
fn print(&self);
}
struct S {
s: int,
}
impl S: T {
fn print(&self) {
io::println(fmt!("%?", self));
}
}
fn print_t(t: &T) {
t.print();
}
fn print_s(s: &S) {
s.print();
}
fn main() {
let s: @S = @S { s: 5 };
print_s(s);
let t: @T = s as @T;
print_t(t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment