add in-place iteration for Zip
this picks the left hand side as source since it might be more natural to consume that as IntoIter source
This commit is contained in:
parent
3d5e9f1904
commit
0f122e1119
1 changed files with 24 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
||||||
use crate::cmp;
|
use crate::cmp;
|
||||||
use crate::fmt::{self, Debug};
|
use crate::fmt::{self, Debug};
|
||||||
|
|
||||||
use super::super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen};
|
use super::super::{
|
||||||
|
DoubleEndedIterator, ExactSizeIterator, FusedIterator, InPlaceIterable, Iterator, SourceIter,
|
||||||
|
TrustedLen,
|
||||||
|
};
|
||||||
|
|
||||||
/// An iterator that iterates two other iterators simultaneously.
|
/// An iterator that iterates two other iterators simultaneously.
|
||||||
///
|
///
|
||||||
|
@ -327,6 +330,26 @@ where
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Arbitrarily selects the left side of the zip iteration as extractable "source"
|
||||||
|
// it would require negative trait bounds to be able to try both
|
||||||
|
#[unstable(issue = "0", feature = "inplace_iteration")]
|
||||||
|
unsafe impl<S, A, B> SourceIter for Zip<A, B>
|
||||||
|
where
|
||||||
|
A: SourceIter<Source = S>,
|
||||||
|
B: Iterator,
|
||||||
|
S: Iterator,
|
||||||
|
{
|
||||||
|
type Source = S;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn as_inner(&mut self) -> &mut S {
|
||||||
|
SourceIter::as_inner(&mut self.a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(issue = "0", feature = "inplace_iteration")]
|
||||||
|
unsafe impl<A: InPlaceIterable, B: Iterator> InPlaceIterable for Zip<A, B> {}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<A: Debug, B: Debug> Debug for Zip<A, B> {
|
impl<A: Debug, B: Debug> Debug for Zip<A, B> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
|
Loading…
Reference in a new issue