Skip to content

Instantly share code, notes, and snippets.

@thiagopnts
Created December 18, 2014 20:40
Show Gist options
  • Save thiagopnts/8d4ad8ee8149a5b9ffd9 to your computer and use it in GitHub Desktop.
Save thiagopnts/8d4ad8ee8149a5b9ffd9 to your computer and use it in GitHub Desktop.
trait Foo {
fn foo(&self);
}
#[deriving(Show)]
enum SomeValue {
Value(int)
}
struct Bar {
value: SomeValue
}
impl Bar {
fn new(value: SomeValue) -> Bar {
Bar { value: value }
}
}
impl Foo for Bar {
fn foo(&self) {
use_value(self.value);
}
}
fn use_value(value: SomeValue) {
println!("{}", value);
}
fn main() {
let bar = Bar::new(SomeValue::Value(1));
}
// foo.rs:22:19: 22:23 error: cannot move out of dereference of `&`-pointer
// foo.rs:22 use_value(self.value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment