Skip to content

Instantly share code, notes, and snippets.

@Blei
Created October 20, 2012 18:21
Show Gist options
  • Save Blei/3924261 to your computer and use it in GitHub Desktop.
Save Blei/3924261 to your computer and use it in GitHub Desktop.
No trait!
struct Thing {
x: int
}
impl Thing {
pure fn mul(c: &int) -> Thing {
Thing {x: self.x * *c}
}
}
fn main() {
let u = Thing {x: 2};
let v = u.mul(&3); // Works
let w = u * 3; // Works!!
io::println(fmt!("%i", w.x));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment