Skip to content

Instantly share code, notes, and snippets.

@Aatch
Created June 28, 2013 00:57
Show Gist options
  • Save Aatch/5881675 to your computer and use it in GitHub Desktop.
Save Aatch/5881675 to your computer and use it in GitHub Desktop.
#[allow(default_methods)];
trait Foo {
pub fn visit_crate(&mut self) {
self.visit_mod([1,2,3])
}
pub fn visit_mod(&mut self, a: &[uint]) {
for a.iter().advance |i| {
self.visit_item(i);
}
}
pub fn visit_item(&mut self, _i: &uint) {
}
}
struct Printer;
impl Foo for Printer {
pub fn visit_item(&mut self, _i: &uint) {
println("Item!");
}
}
fn main() {
let mut a = Printer;
a.visit_crate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment