Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/cloned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I> Cloned<I> {
pub(in crate::iter) fn new(it: I) -> Cloned<I> {
Cloned { it }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.it
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.it
}
}

fn clone_try_fold<T: Clone, Acc, R>(mut f: impl FnMut(Acc, T) -> R) -> impl FnMut(Acc, &T) -> R {
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/copied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ impl<I> Copied<I> {
pub(in crate::iter) fn new(it: I) -> Copied<I> {
Copied { it }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.it
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.it
}
}

fn copy_fold<T: Copy, Acc>(mut f: impl FnMut(Acc, T) -> Acc) -> impl FnMut(Acc, &T) -> Acc {
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I> Enumerate<I> {
pub(in crate::iter) fn new(iter: I) -> Enumerate<I> {
Enumerate { iter, count: 0 }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I, P> Filter<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> Filter<I, P> {
Filter { iter, predicate }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ impl<I, F> FilterMap<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> FilterMap<I, F> {
FilterMap { iter, f }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I, F> Inspect<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> Inspect<I, F> {
Inspect { iter, f }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/intersperse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ where
pub(in crate::iter) fn new(iter: I, separator: I::Item) -> Self {
Self { iter: iter.peekable(), separator, needs_sep: false }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter.inner()
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter.into_inner()
}
}

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ impl<I, F> Map<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> Map<I, F> {
Map { iter, f }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/map_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I, P> MapWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> MapWhile<I, P> {
MapWhile { iter, predicate }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "iter_map_while", since = "1.57.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/peekable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I: Iterator> Peekable<I> {
pub(in crate::iter) fn new(iter: I) -> Peekable<I> {
Peekable { iter, peeked: None }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the peekable and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

// Peekable must remember if a None has been seen in the `.peek()` method.
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/rev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ impl<T> Rev<T> {
pub(in crate::iter) fn new(iter: T) -> Rev<T> {
Rev { iter }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &T {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> T {
self.iter
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I, St, F> Scan<I, St, F> {
pub(in crate::iter) fn new(iter: I, state: St, f: F) -> Scan<I, St, F> {
Scan { iter, state, f }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I> Skip<I> {
pub(in crate::iter) fn new(iter: I, n: usize) -> Skip<I> {
Skip { iter, n }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/skip_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I, P> SkipWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> SkipWhile<I, P> {
SkipWhile { iter, flag: false, predicate }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I> StepBy<I> {
assert!(step != 0);
StepBy { iter, step: step - 1, first_take: true }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "iterator_step_by", since = "1.28.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl<I> Take<I> {
pub(in crate::iter) fn new(iter: I, n: usize) -> Take<I> {
Take { iter, n }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 12 additions & 0 deletions library/core/src/iter/adapters/take_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl<I, P> TakeWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> TakeWhile<I, P> {
TakeWhile { iter, flag: false, predicate }
}

/// Returns a reference to the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn inner(&self) -> &I {
&self.iter
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> I {
self.iter
}
}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
18 changes: 18 additions & 0 deletions library/core/src/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ impl<A: Iterator, B: Iterator> Zip<A, B> {
}
None
}

/// Returns a reference to the left inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn left_inner(&self) -> &A {
&self.a
}

/// Returns a reference to the right inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn right_inner(&self) -> &B {
&self.b
}

/// Consumes the adaptor struct and returns the inner iterator.
#[unstable(feature = "inner_adaptor", issue = "103302", reason = "recently added")]
pub fn into_inner(self) -> (A, B) {
(self.a, self.b)
}
}

/// Converts the arguments to iterators and zips them.
Expand Down