|
1 | 1 | use crate::cmp;
|
2 | 2 | use crate::fmt::{self, Debug};
|
3 | 3 |
|
4 |
| -use super::super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen}; |
| 4 | +use super::super::{ |
| 5 | + DoubleEndedIterator, ExactSizeIterator, FusedIterator, InPlaceIterable, Iterator, SourceIter, |
| 6 | + TrustedLen, |
| 7 | +}; |
5 | 8 |
|
6 | 9 | /// An iterator that iterates two other iterators simultaneously.
|
7 | 10 | ///
|
@@ -327,6 +330,26 @@ where
|
327 | 330 | {
|
328 | 331 | }
|
329 | 332 |
|
| 333 | +// Arbitrarily selects the left side of the zip iteration as extractable "source" |
| 334 | +// it would require negative trait bounds to be able to try both |
| 335 | +#[unstable(issue = "0", feature = "inplace_iteration")] |
| 336 | +unsafe impl<S, A, B> SourceIter for Zip<A, B> |
| 337 | + where |
| 338 | + A: SourceIter<Source = S>, |
| 339 | + B: Iterator, |
| 340 | + S: Iterator, |
| 341 | +{ |
| 342 | + type Source = S; |
| 343 | + |
| 344 | + #[inline] |
| 345 | + fn as_inner(&mut self) -> &mut S { |
| 346 | + SourceIter::as_inner(&mut self.a) |
| 347 | + } |
| 348 | +} |
| 349 | + |
| 350 | +#[unstable(issue = "0", feature = "inplace_iteration")] |
| 351 | +unsafe impl<A: InPlaceIterable, B: Iterator> InPlaceIterable for Zip<A, B> {} |
| 352 | + |
330 | 353 | #[stable(feature = "rust1", since = "1.0.0")]
|
331 | 354 | impl<A: Debug, B: Debug> Debug for Zip<A, B> {
|
332 | 355 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
0 commit comments