@@ -798,6 +798,8 @@ impl str {
798
798
///
799
799
/// assert_eq!(None, iter.next());
800
800
/// ```
801
+ #[ must_use = "this returns the split string as an iterator, \
802
+ without modifying the original"]
801
803
#[ stable( feature = "split_whitespace" , since = "1.1.0" ) ]
802
804
#[ inline]
803
805
pub fn split_whitespace ( & self ) -> SplitWhitespace < ' _ > {
@@ -839,6 +841,8 @@ impl str {
839
841
///
840
842
/// assert_eq!(None, iter.next());
841
843
/// ```
844
+ #[ must_use = "this returns the split string as an iterator, \
845
+ without modifying the original"]
842
846
#[ stable( feature = "split_ascii_whitespace" , since = "1.34.0" ) ]
843
847
#[ inline]
844
848
pub fn split_ascii_whitespace ( & self ) -> SplitAsciiWhitespace < ' _ > {
@@ -914,6 +918,8 @@ impl str {
914
918
///
915
919
/// assert!(utf16_len <= utf8_len);
916
920
/// ```
921
+ #[ must_use = "this returns the encoded string as an iterator, \
922
+ without modifying the original"]
917
923
#[ stable( feature = "encode_utf16" , since = "1.8.0" ) ]
918
924
pub fn encode_utf16 ( & self ) -> EncodeUtf16 < ' _ > {
919
925
EncodeUtf16 { chars : self . chars ( ) , extra : 0 }
@@ -1840,6 +1846,8 @@ impl str {
1840
1846
/// let s = " עברית";
1841
1847
/// assert!(Some('ע') == s.trim_left().chars().next());
1842
1848
/// ```
1849
+ #[ must_use = "this returns the trimmed string as a new slice, \
1850
+ without modifying the original"]
1843
1851
#[ inline]
1844
1852
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1845
1853
#[ rustc_deprecated(
@@ -1882,6 +1890,8 @@ impl str {
1882
1890
/// let s = "עברית ";
1883
1891
/// assert!(Some('ת') == s.trim_right().chars().rev().next());
1884
1892
/// ```
1893
+ #[ must_use = "this returns the trimmed string as a new slice, \
1894
+ without modifying the original"]
1885
1895
#[ inline]
1886
1896
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1887
1897
#[ rustc_deprecated(
@@ -2346,6 +2356,8 @@ impl str {
2346
2356
/// ```
2347
2357
/// assert_eq!("❤\n!".escape_debug().to_string(), "❤\\n!");
2348
2358
/// ```
2359
+ #[ must_use = "this returns the escaped string as an iterator, \
2360
+ without modifying the original"]
2349
2361
#[ stable( feature = "str_escape" , since = "1.34.0" ) ]
2350
2362
pub fn escape_debug ( & self ) -> EscapeDebug < ' _ > {
2351
2363
let mut chars = self . chars ( ) ;
@@ -2390,6 +2402,8 @@ impl str {
2390
2402
/// ```
2391
2403
/// assert_eq!("❤\n!".escape_default().to_string(), "\\u{2764}\\n!");
2392
2404
/// ```
2405
+ #[ must_use = "this returns the escaped string as an iterator, \
2406
+ without modifying the original"]
2393
2407
#[ stable( feature = "str_escape" , since = "1.34.0" ) ]
2394
2408
pub fn escape_default ( & self ) -> EscapeDefault < ' _ > {
2395
2409
EscapeDefault { inner : self . chars ( ) . flat_map ( CharEscapeDefault ) }
@@ -2426,6 +2440,8 @@ impl str {
2426
2440
/// ```
2427
2441
/// assert_eq!("❤\n!".escape_unicode().to_string(), "\\u{2764}\\u{a}\\u{21}");
2428
2442
/// ```
2443
+ #[ must_use = "this returns the escaped string as an iterator, \
2444
+ without modifying the original"]
2429
2445
#[ stable( feature = "str_escape" , since = "1.34.0" ) ]
2430
2446
pub fn escape_unicode ( & self ) -> EscapeUnicode < ' _ > {
2431
2447
EscapeUnicode { inner : self . chars ( ) . flat_map ( CharEscapeUnicode ) }
0 commit comments