Skip to content

Instantly share code, notes, and snippets.

@m10e
Created May 30, 2014 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m10e/9a182cf60fd907a47999 to your computer and use it in GitHub Desktop.
Save m10e/9a182cf60fd907a47999 to your computer and use it in GitHub Desktop.
System:
rustc 0.11.0-pre-nightly (022a7b3 2014-05-22 01:06:25 -0700)
host: x86_64-apple-darwin
Error:
main.rs:14:2: 14:7 error: mismatched types: expected `Box A` but found `~B` (expected trait A but found box)
main.rs:14 box B
^~~~~
error: aborting due to previous error
// -------------------- main.rs
trait A {
fn do_stuff(&self);
}
struct B;
impl A for B {
fn do_stuff(&self) {
println!("Stuff.");
}
}
fn new_a() -> Box<A> {
box B
}
fn main() {
let a = new_a();
a.do_stuff();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment