diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-02-07 18:30:34 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-02-07 22:04:38 -0500 |
| commit | e01824477751561fa0c1c13db13d0fbda341008e (patch) | |
| tree | 883dda4c4ac8c5c4e4a8c48c89cfbf90e5306a65 /src/libstd | |
| parent | f6e0df6563830a930188760bbefdc080d9c0902f (diff) | |
make Option's map and map_default use a lifetime
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/treemap.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index e79025a7955..da83c7b789b 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -556,24 +556,18 @@ impl <K: Ord, V> TreeNode<K, V> { pure fn each<K: Ord, V>(node: &r/Option<~TreeNode<K, V>>, f: fn(&(&r/K, &r/V)) -> bool) { - match *node { - Some(ref x) => { + do node.map |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } - } - None => () - } + }; } pure fn each_reverse<K: Ord, V>(node: &r/Option<~TreeNode<K, V>>, f: fn(&(&r/K, &r/V)) -> bool) { - match *node { - Some(ref x) => { + do node.map |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } - } - None => () - } + }; } // Remove left horizontal link by rotating right |
