about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorJeremy Smart <jeremy3141592@gmail.com>2025-07-21 21:44:48 -0400
committerJeremy Smart <jeremy3141592@gmail.com>2025-07-23 22:03:03 -0400
commit6f1b56c499a0b4a5930067814cee5538eaab700a (patch)
tree487ec5b7991ac9d4b6f426ffe04da9036d4e0723 /library/core
parent9748d87dc70a9a6725c5dbd76ce29d04752b4f90 (diff)
downloadrust-6f1b56c499a0b4a5930067814cee5538eaab700a.tar.gz
rust-6f1b56c499a0b4a5930067814cee5538eaab700a.zip
add Rev::into_inner
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/iter/adapters/rev.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/core/src/iter/adapters/rev.rs b/library/core/src/iter/adapters/rev.rs
index 06ab15d5e90..17d3eef597d 100644
--- a/library/core/src/iter/adapters/rev.rs
+++ b/library/core/src/iter/adapters/rev.rs
@@ -20,6 +20,25 @@ impl<T> Rev<T> {
     pub(in crate::iter) fn new(iter: T) -> Rev<T> {
         Rev { iter }
     }
+
+    /// Consumes the `Rev`, returning the inner iterator.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// #![feature(rev_into_inner)]
+    ///
+    /// let s = "foobar";
+    /// let mut rev = s.chars().rev();
+    /// assert_eq!(rev.next(), Some('r'));
+    /// assert_eq!(rev.next(), Some('a'));
+    /// assert_eq!(rev.next(), Some('b'));
+    /// assert_eq!(rev.into_inner().collect::<String>(), "foo");
+    /// ```
+    #[unstable(feature = "rev_into_inner", issue = "144277")]
+    pub fn into_inner(self) -> T {
+        self.iter
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]