File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2462,6 +2462,32 @@ impl Drop for Drain<'_> {
24622462 }
24632463}
24642464
2465+ impl < ' a > Drain < ' a > {
2466+ /// Returns the remaining (sub)string of this iterator as a slice.
2467+ ///
2468+ /// # Examples
2469+ ///
2470+ /// ```
2471+ /// #![feature(string_drain_as_str)]
2472+ /// let mut s = String::from("abc");
2473+ /// let mut drain = s.drain(..);
2474+ /// assert_eq!(drain.as_str(), "abc");
2475+ /// let _ = drain.next().unwrap();
2476+ /// assert_eq!(drain.as_str(), "bc");
2477+ /// ```
2478+ #[ unstable( feature = "string_drain_as_str" , issue = "none" ) ]
2479+ pub fn as_str ( & self ) -> & str {
2480+ self . iter . as_str ( )
2481+ }
2482+ }
2483+
2484+ #[ unstable( feature = "string_drain_as_str" , issue = "none" ) ]
2485+ impl < ' a > AsRef < str > for Drain < ' a > {
2486+ fn as_ref ( & self ) -> & str {
2487+ self . as_str ( )
2488+ }
2489+ }
2490+
24652491#[ stable( feature = "drain" , since = "1.6.0" ) ]
24662492impl Iterator for Drain < ' _ > {
24672493 type Item = char ;
You can’t perform that action at this time.
0 commit comments