Use while let

This commit is contained in:
Mikhail Zabaluev 2015-02-22 23:46:36 +02:00
parent f9b70acfd4
commit 7b464d364b

View File

@ -1479,22 +1479,15 @@ fn extend_desugared<I: Iterator<Item=T>>(&mut self, mut iterator: I) {
// for item in iterator {
// self.push(item);
// }
loop {
match iterator.next() {
None => {
break;
}
Some(element) => {
let len = self.len();
if len == self.capacity() {
let (lower, _) = iterator.size_hint();
self.reserve(lower + 1);
}
unsafe {
ptr::write(self.get_unchecked_mut(len), element);
self.set_len(len + 1);
}
}
while let Some(element) = iterator.next() {
let len = self.len();
if len == self.capacity() {
let (lower, _) = iterator.size_hint();
self.reserve(lower + 1);
}
unsafe {
ptr::write(self.get_unchecked_mut(len), element);
self.set_len(len + 1);
}
}
}