Skip to content

Commit c2b4796

Browse files
committed
---
yaml --- r: 60321 b: refs/heads/master c: 043d022 h: refs/heads/master i: 60319: 71a2d74 v: v3
1 parent 448e4b1 commit c2b4796

File tree

7 files changed

+56
-132
lines changed

7 files changed

+56
-132
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b9824e18c2b02d74bd1bf646fea5f05477ca5071
2+
refs/heads/master: 043d02213e19c5a5cffb781e5a11accbe28bf0de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/vec.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,8 @@ pub trait ImmutableVector<'self, T> {
20712071
fn initn(&self, n: uint) -> &'self [T];
20722072
fn last(&self) -> &'self T;
20732073
fn last_opt(&self) -> Option<&'self T>;
2074+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
2075+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
20742076
#[cfg(stage0)]
20752077
fn each_reverse(&self, blk: &fn(&T) -> bool);
20762078
#[cfg(not(stage0))]
@@ -2138,6 +2140,30 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
21382140
#[inline]
21392141
fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
21402142

2143+
/**
2144+
* Find the first index matching some predicate
2145+
*
2146+
* Apply function `f` to each element of `v`. When function `f` returns
2147+
* true then an option containing the index is returned. If `f` matches no
2148+
* elements then none is returned.
2149+
*/
2150+
#[inline]
2151+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2152+
position(*self, f)
2153+
}
2154+
2155+
/**
2156+
* Find the last index matching some predicate
2157+
*
2158+
* Apply function `f` to each element of `v` in reverse order. When
2159+
* function `f` returns true then an option containing the index is
2160+
* returned. If `f` matches no elements then none is returned.
2161+
*/
2162+
#[inline]
2163+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2164+
rposition(*self, f)
2165+
}
2166+
21412167
/// Iterates over a vector's elements in reverse.
21422168
#[inline]
21432169
#[cfg(stage0)]
@@ -2230,43 +2256,17 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
22302256
}
22312257

22322258
pub trait ImmutableEqVector<T:Eq> {
2233-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22342259
fn position_elem(&self, t: &T) -> Option<uint>;
2235-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22362260
fn rposition_elem(&self, t: &T) -> Option<uint>;
22372261
}
22382262

22392263
impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
2240-
/**
2241-
* Find the first index matching some predicate
2242-
*
2243-
* Apply function `f` to each element of `v`. When function `f` returns
2244-
* true then an option containing the index is returned. If `f` matches no
2245-
* elements then none is returned.
2246-
*/
2247-
#[inline]
2248-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2249-
position(*self, f)
2250-
}
2251-
22522264
/// Find the first index containing a matching value
22532265
#[inline]
22542266
fn position_elem(&self, x: &T) -> Option<uint> {
22552267
position_elem(*self, x)
22562268
}
22572269

2258-
/**
2259-
* Find the last index matching some predicate
2260-
*
2261-
* Apply function `f` to each element of `v` in reverse order. When
2262-
* function `f` returns true then an option containing the index is
2263-
* returned. If `f` matches no elements then none is returned.
2264-
*/
2265-
#[inline]
2266-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2267-
rposition(*self, f)
2268-
}
2269-
22702270
/// Find the last index containing a matching value
22712271
#[inline]
22722272
fn rposition_elem(&self, t: &T) -> Option<uint> {

trunk/src/libstd/fun_treemap.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,45 @@ enum TreeNode<K, V> {
3333
pub fn init<K, V>() -> Treemap<K, V> { @Empty }
3434

3535
/// Insert a value into the map
36-
pub fn insert<K:Copy + Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K, v: V) -> Treemap<K, V> {
36+
pub fn insert<K:Copy + Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K, v: V)
37+
-> Treemap<K, V> {
3738
@match m {
38-
@Empty => Node(@k, @v, @Empty, @Empty),
39-
@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) }
42-
_ { Node(@kk, vv, left, insert(right, k, v)) }
43-
)
44-
}
39+
@Empty => Node(@k, @v, @Empty, @Empty),
40+
@Node(@copy kk, vv, left, right) => {
41+
if k < kk {
42+
Node(@kk, vv, insert(left, k, v), right)
43+
} else if k == kk {
44+
Node(@kk, @v, left, right)
45+
} else { Node(@kk, vv, left, insert(right, k, v)) }
46+
}
47+
}
4548
}
4649

4750
/// Find a value based on the key
4851
pub fn find<K:Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
4952
match *m {
50-
Empty => None,
51-
Node(@ref kk, @copy v, left, right) => cond!(
52-
| k == *kk { Some(v) }
53-
| k < *kk { find(left, k) }
54-
_ { find(right, k) }
55-
)
53+
Empty => None,
54+
Node(@ref kk, @copy v, left, right) => {
55+
if k == *kk {
56+
Some(v)
57+
} else if k < *kk { find(left, k) } else { find(right, k) }
58+
}
5659
}
5760
}
5861

5962
/// Visit all pairs in the map in order.
6063
pub fn traverse<K, V: Copy>(m: Treemap<K, V>, f: &fn(&K, &V)) {
6164
match *m {
62-
Empty => (),
63-
// Previously, this had what looked like redundant
64-
// matches to me, so I changed it. but that may be a
65-
// de-optimization -- tjc
66-
Node(@ref k, @ref v, left, right) => {
67-
traverse(left, f);
68-
f(k, v);
69-
traverse(right, f);
70-
}
65+
Empty => (),
66+
/*
67+
Previously, this had what looked like redundant
68+
matches to me, so I changed it. but that may be a
69+
de-optimization -- tjc
70+
*/
71+
Node(@ref k, @ref v, left, right) => {
72+
traverse(left, f);
73+
f(k, v);
74+
traverse(right, f);
75+
}
7176
}
7277
}

trunk/src/libstd/std.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ pub mod flatpipes;
6363

6464
pub mod bitv;
6565
pub mod deque;
66-
#[cfg(not(stage0))]
6766
pub mod fun_treemap;
6867
pub mod list;
6968
pub mod priority_queue;

trunk/src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -542,41 +542,7 @@ pub fn core_macros() -> ~str {
542542
}
543543
)
544544

545-
//
546-
// A scheme-style conditional that helps to improve code clarity in some instances when
547-
// the `if`, `else if`, and `else` keywords obscure predicates undesirably.
548-
//
549-
// # Example
550-
//
551-
// ~~~
552-
// let clamped =
553-
// if x > mx { mx }
554-
// else if x < mn { mn }
555-
// else { x };
556-
// ~~~
557-
//
558-
// Using `cond!`, the above could be written as:
559-
//
560-
// ~~~
561-
// let clamped = cond!(
562-
// | x > mx { mx }
563-
// | x < mn { mn }
564-
// _ { x }
565-
// );
566-
// ~~~
567-
//
568-
// The optional default case is denoted by `_`.
569-
//
570-
macro_rules! cond (
571-
($( | $pred:expr $body:block)+ _ $default:block ) => (
572-
$(if $pred $body else)+
573-
$default
574-
);
575-
// for if the default case was ommitted
576-
( $( | $pred:expr $body:block )+ ) => (
577-
$(if $pred $body)else+
578-
);
579-
)
545+
580546
}";
581547
}
582548

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

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)