auto merge of #9291 : jzelinskie/rust/remove-cond, r=alexcrichton

This is my first contribution, so please point out anything that I may have missed.

I consulted IRC and settled on `match () { ... }` for most of the replacements.
This commit is contained in:
bors 2013-09-19 00:31:05 -07:00
commit a7cf7b7b0b
8 changed files with 55 additions and 137 deletions

View file

@ -894,42 +894,6 @@ pub fn std_macros() -> @str {
}
)
//
// A scheme-style conditional that helps to improve code clarity in some instances when
// the `if`, `else if`, and `else` keywords obscure predicates undesirably.
//
// # Example
//
// ~~~
// let clamped =
// if x > mx { mx }
// else if x < mn { mn }
// else { x };
// ~~~
//
// Using `cond!`, the above could be written as:
//
// ~~~
// let clamped = cond!(
// (x > mx) { mx }
// (x < mn) { mn }
// _ { x }
// );
// ~~~
//
// The optional default case is denoted by `_`.
//
macro_rules! cond (
( $(($pred:expr) $body:block)+ _ $default:block ) => (
$(if $pred $body else)+
$default
);
// for if the default case was ommitted
( $(($pred:expr) $body:block)+ ) => (
$(if $pred $body)else+
);
)
// NOTE(acrichto): start removing this after the next snapshot
macro_rules! printf (
($arg:expr) => (