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

adjust libcore

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