[][src]Macro faux::when

macro_rules! when {
    #[proc_macro_hack::proc_macro_hack] => { ... };
}

Creates a When for a specific instance/method pair

This macro is a wrapper around calling the _when_{method_name}() method that is auto-generated by #[methods].

#[faux::create]
pub struct Foo {}

#[faux::methods]
impl Foo {
    pub fn some_method(&self, a: u32, b: i8) -> i32 {
        /* implementation code */
    }
}

fn main() {
    let mut mock = Foo::faux();
    // input and output types are stored in the type signature of `When`
    // calling `when!` or the auto-generated method creates the same `When`
    let a: faux::When<(u32, i8), i32> = faux::when!(mock.some_method);
    let b: faux::When<(u32, i8), i32> = mock._when_some_method();
}