Crates.io | macro-utils |
lib.rs | macro-utils |
version | 0.1.3 |
source | src |
created_at | 2018-07-06 22:38:55.20617 |
updated_at | 2019-05-01 11:05:00.724724 |
description | Some macros to make code writing more elegant and funny. |
homepage | https://github.com/GuillaumeGomez/macro_utils |
repository | https://github.com/GuillaumeGomez/macro_utils |
max_upload_size | |
id | 73156 |
size | 18,136 |
Some macros to help writing better code or just having fun.
To use it in your project, just add the following lines:
#[macro_use]
extern crate macro_utils;
#[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" } };
}