auto merge of #5395 : thestinger/rust/iter, r=pcwalton

This commit is contained in:
bors 2013-03-15 09:21:56 -07:00
commit c724dae7de
2 changed files with 13 additions and 15 deletions

View file

@ -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;
@ -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)]

View file

@ -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> {
@ -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;
@ -718,7 +709,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
}
*node = None;
return true;
true
}
#[cfg(test)]