Skip to content

Commit 7e4a176

Browse files
committed
Use parentheses for cond! macro instead of preceding pipes
This is temporary. Once the macro parser has improved or been re-written these can be removed.
1 parent b9824e1 commit 7e4a176

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/libstd/fun_treemap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub fn insert<K:Copy + Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K, v: V) -> Treemap
3737
@match m {
3838
@Empty => Node(@k, @v, @Empty, @Empty),
3939
@Node(@copy kk, vv, left, right) => cond!(
40-
| k < kk { Node(@kk, vv, insert(left, k, v), right) }
41-
| k == kk { Node(@kk, @v, left, right) }
40+
(k < kk) { Node(@kk, vv, insert(left, k, v), right) }
41+
(k == kk) { Node(@kk, @v, left, right) }
4242
_ { Node(@kk, vv, left, insert(right, k, v)) }
4343
)
4444
}
@@ -49,8 +49,8 @@ pub fn find<K:Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
4949
match *m {
5050
Empty => None,
5151
Node(@ref kk, @copy v, left, right) => cond!(
52-
| k == *kk { Some(v) }
53-
| k < *kk { find(left, k) }
52+
(k == *kk) { Some(v) }
53+
(k < *kk) { find(left, k) }
5454
_ { find(right, k) }
5555
)
5656
}

src/libsyntax/ext/expand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,21 +559,21 @@ pub fn core_macros() -> ~str {
559559
//
560560
// ~~~
561561
// let clamped = cond!(
562-
// | x > mx { mx }
563-
// | x < mn { mn }
562+
// (x > mx) { mx }
563+
// (x < mn) { mn }
564564
// _ { x }
565565
// );
566566
// ~~~
567567
//
568568
// The optional default case is denoted by `_`.
569569
//
570570
macro_rules! cond (
571-
($( | $pred:expr $body:block)+ _ $default:block ) => (
571+
( $(($pred:expr) $body:block)+ _ $default:block ) => (
572572
$(if $pred $body else)+
573573
$default
574574
);
575575
// for if the default case was ommitted
576-
( $( | $pred:expr $body:block )+ ) => (
576+
( $(($pred:expr) $body:block)+ ) => (
577577
$(if $pred $body)else+
578578
);
579579
)

src/test/run-pass/cond-macro-no-default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
1212
cond!(
13-
| x > mx { return mx; }
14-
| x < mn { return mn; }
13+
(x > mx) { return mx; }
14+
(x < mn) { return mn; }
1515
)
1616
return x;
1717
}
@@ -20,4 +20,4 @@ fn main() {
2020
assert_eq!(clamp(1, 2, 4), 2);
2121
assert_eq!(clamp(8, 2, 4), 4);
2222
assert_eq!(clamp(3, 2, 4), 3);
23-
}
23+
}

src/test/run-pass/cond-macro.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
1212
cond!(
13-
| x > mx { mx }
14-
| x < mn { mn }
13+
(x > mx) { mx }
14+
(x < mn) { mn }
1515
_ { x }
1616
)
1717
}
@@ -20,4 +20,4 @@ fn main() {
2020
assert_eq!(clamp(1, 2, 4), 2);
2121
assert_eq!(clamp(8, 2, 4), 4);
2222
assert_eq!(clamp(3, 2, 4), 3);
23-
}
23+
}

0 commit comments

Comments
 (0)