diff options
| author | bors <bors@rust-lang.org> | 2013-05-14 18:11:00 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-14 18:11:00 -0700 |
| commit | cf0f760560385d59427e2b974f24a328345d829b (patch) | |
| tree | 76edbcad601f3f438eecdd5c38a15f1a944bd526 /src/rt/jemalloc/test/aligned_alloc.c | |
| parent | c30414f980eb3e8010640f6c83a5ef6f8e6ab047 (diff) | |
| parent | 7e4a176dd3a1789d5d10cb995a62daa185cb9cdd (diff) | |
| download | rust-cf0f760560385d59427e2b974f24a328345d829b.tar.gz rust-cf0f760560385d59427e2b974f24a328345d829b.zip | |
auto merge of #6333 : bjz/rust/cond-macro, r=thestinger
Addressing issue #6037, this Scheme-style conditional helps to improve code clarity in instances where the `if`, `else if`, and `else` keywords obscure predicates undesirably.
Here is an example:
~~~rust
let clamped =
if x > mx { mx }
else if x < mn { mn }
else { x };
~~~
Using `cond!`, the above could be written as:
~~~rust
let clamped = cond!(
(x > mx) { mx }
(x < mn) { mn }
_ { x }
);
~~~
The optional default case is denoted by `_`.
I have altered `std::fun_treemap` to demonstrate it in use. I am definitely interested in using it for some of the numeric functions, but I will have to wait for it to reach `stage0` first.
Diffstat (limited to 'src/rt/jemalloc/test/aligned_alloc.c')
0 files changed, 0 insertions, 0 deletions
