#funny #elegant #macro #macro-use #fun

macro-utils

Some macros to make code writing more elegant and funny

4 releases

Uses old Rust 2015

0.1.3 May 1, 2019
0.1.2 Jul 7, 2018
0.1.1 Jul 6, 2018
0.1.0 Jul 6, 2018

#2107 in Rust patterns

Download history 981/week @ 2025-12-09 262/week @ 2025-12-16 221/week @ 2025-12-23 219/week @ 2025-12-30 140/week @ 2026-01-06 196/week @ 2026-01-13 256/week @ 2026-01-20 223/week @ 2026-01-27 265/week @ 2026-02-03 228/week @ 2026-02-10 658/week @ 2026-02-17 635/week @ 2026-02-24 14178/week @ 2026-03-03 4238/week @ 2026-03-10 913/week @ 2026-03-17 749/week @ 2026-03-24

20,474 downloads per month

MIT license

17KB
186 lines

Build Status Build status

macro-utils

Some macros to help writing better code or just having fun.

Usage

To use it in your project, just add the following lines:

#[macro_use]
extern crate macro_utils;

Examples

#[macro_use]
extern crate macro_utils;

fn main() {
    let s = "bateau";

    if_match! {
        s == "voiture" => println!("It rolls!"),
        s == "avion"   => println!("It flies!"),
        s == "pieds"   => println!("It walks!"),
        s == "fusée"   => println!("It goes through space!"),
        s == "bateau"  => println!("It moves on water!"),
        else           => println!("I dont't know how it moves...")
    }

    let y = 4;
    let x = tern_c! { (y & 1 == 0) ? { "even" } : { "odd" } };
    let x = tern_python! { { "it's even" } if (y & 1 == 0) else { "it's odd" } };
    let x = tern_haskell! { if (y & 1 == 0) then { "it's even" } else { "it's odd" } };
}

No runtime deps