提交 37df5e0b 编写于 作者: A Ariel Ben-Yehuda

adjust libcore

上级 6b9fbb2a
......@@ -1084,9 +1084,11 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
pub fn map<U: ?Sized, F>(orig: RefMut<'b, T>, f: F) -> RefMut<'b, U>
where F: FnOnce(&mut T) -> &mut U
{
// FIXME: fix borrow-check
let RefMut { value, borrow } = orig;
RefMut {
value: f(orig.value),
borrow: orig.borrow,
value: f(value),
borrow: borrow,
}
}
}
......
......@@ -1776,12 +1776,18 @@ fn count(mut self) -> usize {
#[inline]
fn nth(&mut self, n: usize) -> Option<I::Item> {
match self.peeked.take() {
// the .take() below is just to avoid "move into pattern guard"
Some(ref mut v) if n == 0 => v.take(),
Some(None) => None,
Some(Some(_)) => self.iter.nth(n - 1),
None => self.iter.nth(n),
// FIXME: merge these when borrow-checking gets better.
if n == 0 {
match self.peeked.take() {
Some(v) => v,
None => self.iter.nth(n),
}
} else {
match self.peeked.take() {
Some(None) => None,
Some(Some(_)) => self.iter.nth(n - 1),
None => self.iter.nth(n),
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册