defmac 0.1.1

A macro to define lambda-like macros inline.
Documentation

A macro to define lambda-like macros inline.

Syntax:

defmac!( name [ pattern [, pattern ... ]] => expression )

name is the name of the new macro, followed by 0 or more patterns separated by comma. A pattern can be just an argument name like x or a pattern like ref value, (x, y) etc.

Supports up to four arguments.

Example

#[macro_use] extern crate defmac;

fn main() {
    defmac!(mkvec iter => iter.into_iter().collect::<Vec<_>>());

    let v = mkvec!((0..10).map(|x| x * 2));

    defmac!(repeat ref s, n => (0..n).map(|_| &s[..]).collect::<String>());

    let text = String::from("abc");
    let s = repeat!(text, 10);
    let t = repeat!("-", s.len());
    println!("{}", s);
    println!("{}", t);

}