mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 06:43:20 +03:00
Remove unzip() SizeHint hack
This was using an invalid iterator so is likely to end with buggy behaviour. It also doesn't even benefit many type in std including Vec so removing it shouldn't cause any problems.
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
use clone::Clone;
|
||||
use cmp::{Ord, PartialOrd, PartialEq, Ordering};
|
||||
use default::Default;
|
||||
use marker;
|
||||
use num::{Zero, One};
|
||||
use ops::{Add, FnMut, Mul};
|
||||
use option::Option::{self, Some, None};
|
||||
@@ -1747,23 +1746,9 @@ fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
|
||||
FromB: Default + Extend<B>,
|
||||
Self: Sized + Iterator<Item=(A, B)>,
|
||||
{
|
||||
struct SizeHint<A>(usize, Option<usize>, marker::PhantomData<A>);
|
||||
impl<A> Iterator for SizeHint<A> {
|
||||
type Item = A;
|
||||
|
||||
fn next(&mut self) -> Option<A> { None }
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(self.0, self.1)
|
||||
}
|
||||
}
|
||||
|
||||
let (lo, hi) = self.size_hint();
|
||||
let mut ts: FromA = Default::default();
|
||||
let mut us: FromB = Default::default();
|
||||
|
||||
ts.extend(SizeHint(lo, hi, marker::PhantomData));
|
||||
us.extend(SizeHint(lo, hi, marker::PhantomData));
|
||||
|
||||
for (t, u) in self {
|
||||
ts.extend(Some(t));
|
||||
us.extend(Some(u));
|
||||
|
||||
Reference in New Issue
Block a user