mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
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,7 +1,10 @@
|
||||
use crate::cmp;
|
||||
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.
|
||||
///
|
||||
@ -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")]
|
||||
impl<A: Debug, B: Debug> Debug for Zip<A, B> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
Loading…
Reference in New Issue
Block a user