]> git.proxmox.com Git - rustc.git/blob - vendor/macro-utils/README.md
New upstream version 1.62.1+dfsg1
[rustc.git] / vendor / macro-utils / README.md
1 [![Build Status](https://api.travis-ci.org/GuillaumeGomez/macro-utils.png?branch=master)](https://travis-ci.org/GuillaumeGomez/macro-utils) [![Build status](https://ci.appveyor.com/api/projects/status/xnoltw6xvdyj70k6?svg=true)](https://ci.appveyor.com/project/GuillaumeGomez/macro-utils)
2
3 # macro-utils
4
5 Some macros to help writing better code or just having fun.
6
7 ## Usage
8
9 To use it in your project, just add the following lines:
10
11 ```rust,ignore
12 #[macro_use]
13 extern crate macro_utils;
14 ```
15
16 ### Examples
17
18 ```rust
19 #[macro_use]
20 extern crate macro_utils;
21
22 fn main() {
23 let s = "bateau";
24
25 if_match! {
26 s == "voiture" => println!("It rolls!"),
27 s == "avion" => println!("It flies!"),
28 s == "pieds" => println!("It walks!"),
29 s == "fusée" => println!("It goes through space!"),
30 s == "bateau" => println!("It moves on water!"),
31 else => println!("I dont't know how it moves...")
32 }
33
34 let y = 4;
35 let x = tern_c! { (y & 1 == 0) ? { "even" } : { "odd" } };
36 let x = tern_python! { { "it's even" } if (y & 1 == 0) else { "it's odd" } };
37 let x = tern_haskell! { if (y & 1 == 0) then { "it's even" } else { "it's odd" } };
38 }
39 ```