Skip to content

Commit

Permalink
auto merge of #5395 : thestinger/rust/iter, r=pcwalton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Mar 15, 2013
2 parents 19bb166 + a49ccee commit c724dae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
9 changes: 8 additions & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use ops::Add;
use kinds::Copy;
use util;
use num::Zero;
use iter::BaseIter;
use iter::{BaseIter, MutableIter};

#[cfg(test)] use ptr;
#[cfg(test)] use str;
Expand Down Expand Up @@ -323,6 +323,13 @@ impl<T> BaseIter<T> for Option<T> {
}
}
impl<T> MutableIter<T> for Option<T> {
#[inline(always)]
fn each_mut(&mut self, f: &fn(&'self mut T) -> bool) {
match *self { None => (), Some(ref mut t) => { f(t); } }
}
}
pub impl<T> Option<T> {
/// Returns true if the option equals `none`
#[inline(always)]
Expand Down
19 changes: 5 additions & 14 deletions src/libstd/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pure fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
}
};

return a_len < b_len;
a_len < b_len
}

impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
Expand Down Expand Up @@ -694,22 +694,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,

skew(save);

match save.right {
Some(ref mut right) => {
for save.right.each_mut |right| {
skew(right);
match right.right {
Some(ref mut x) => { skew(x) },
None => ()
}
}
None => ()
for right.right.each_mut |x| { skew(x) }
}

split(save);
match save.right {
Some(ref mut x) => { split(x) },
None => ()
}
for save.right.each_mut |x| { split(x) }
}

return removed;
Expand All @@ -718,7 +709,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
}

*node = None;
return true;
true
}

#[cfg(test)]
Expand Down

0 comments on commit c724dae

Please sign in to comment.