[][src]Macro game::callback

macro_rules! callback {
    ($t:ident :: $m:ident) => { ... };
}

A generic version of a callback

Example

#[macro_use(callback)]
trait Command {
    fn run(&self) {}
}
struct Test { x: i32 }
impl Test {
    fn new() -> Test { Test{ x: 42} }
}
impl Command for Test {
    fn run(&self) { println!("{:?}", self.x); }
}
fn main() {
    let mut t = Test::new();
    let macro_test = callback!(Command::run);
    println!("{:?}", macro_test(&mut t as &mut Command) )
}