diff options
| author | Clar Charr <clar@charr.xyz> | 2018-04-04 19:10:38 -0400 |
|---|---|---|
| committer | Clar Charr <clar@charr.xyz> | 2018-04-04 19:10:38 -0400 |
| commit | 5c58eec0bd8cee8fb2a191396d5ad5b5c9b0116a (patch) | |
| tree | 008deaf9de29022f5d794bbedf739049a5eca248 /src/liballoc/vec.rs | |
| parent | 178becdd7c86d87b24951af18e4b7d45f3e1e7bc (diff) | |
| download | rust-5c58eec0bd8cee8fb2a191396d5ad5b5c9b0116a.tar.gz rust-5c58eec0bd8cee8fb2a191396d5ad5b5c9b0116a.zip | |
Replace manual iter exhaust with for_each(drop).
Diffstat (limited to 'src/liballoc/vec.rs')
| -rw-r--r-- | src/liballoc/vec.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 2f57c53a6d8..635ffe08e9c 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2354,7 +2354,7 @@ impl<'a, T> DoubleEndedIterator for Drain<'a, T> { impl<'a, T> Drop for Drain<'a, T> { fn drop(&mut self) { // exhaust self first - while let Some(_) = self.next() {} + self.for_each(drop); if self.tail_len > 0 { unsafe { @@ -2474,9 +2474,7 @@ impl<'a, I: Iterator> ExactSizeIterator for Splice<'a, I> {} #[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> Drop for Splice<'a, I> { fn drop(&mut self) { - // exhaust drain first - while let Some(_) = self.drain.next() {} - + self.drain.by_ref().for_each(drop); unsafe { if self.drain.tail_len == 0 { @@ -2605,8 +2603,7 @@ impl<'a, T, F> Drop for DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool, { fn drop(&mut self) { - for _ in self.by_ref() { } - + self.for_each(drop); unsafe { self.vec.set_len(self.old_len - self.del); } |
