lambda!() { /* proc-macro */ }
Expand description

Helpful macro for generating closure with specified lifetimes. In rust you can’t specify lifetimes for closure but you should, because lifetime inference in closure is dumb. Then this macro will help. Currently, capturing external variables is not possible, but this is in the plans.

Syntax is like anonymous function:

moq::lambda!(
//  asyncness
//  |        
//  |        generic params (lifetimes)
//  |        |
//  |        |    arguments
//  |        |    |
//  |        |    |             return type
//  |        |    |             |
//  vvvvv    vvvv vvvvvvvvvvvv  vvvvvvvvvvvvvvv
    async fn <'a>(arg: &'a str) -> &'static str {
        // ...
    }
)