@@ -798,6 +798,8 @@ impl str {
798798 ///
799799 /// assert_eq!(None, iter.next());
800800 /// ```
801+ #[ must_use = "this returns the split string as an iterator, \
802+ without modifying the original"]
801803 #[ stable( feature = "split_whitespace" , since = "1.1.0" ) ]
802804 #[ inline]
803805 pub fn split_whitespace ( & self ) -> SplitWhitespace < ' _ > {
@@ -839,6 +841,8 @@ impl str {
839841 ///
840842 /// assert_eq!(None, iter.next());
841843 /// ```
844+ #[ must_use = "this returns the split string as an iterator, \
845+ without modifying the original"]
842846 #[ stable( feature = "split_ascii_whitespace" , since = "1.34.0" ) ]
843847 #[ inline]
844848 pub fn split_ascii_whitespace ( & self ) -> SplitAsciiWhitespace < ' _ > {
@@ -914,6 +918,8 @@ impl str {
914918 ///
915919 /// assert!(utf16_len <= utf8_len);
916920 /// ```
921+ #[ must_use = "this returns the encoded string as an iterator, \
922+ without modifying the original"]
917923 #[ stable( feature = "encode_utf16" , since = "1.8.0" ) ]
918924 pub fn encode_utf16 ( & self ) -> EncodeUtf16 < ' _ > {
919925 EncodeUtf16 { chars : self . chars ( ) , extra : 0 }
@@ -1846,6 +1852,8 @@ impl str {
18461852 /// let s = " עברית";
18471853 /// assert!(Some('ע') == s.trim_left().chars().next());
18481854 /// ```
1855+ #[ must_use = "this returns the trimmed string as a new slice, \
1856+ without modifying the original"]
18491857 #[ inline]
18501858 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18511859 #[ rustc_deprecated(
@@ -1888,6 +1896,8 @@ impl str {
18881896 /// let s = "עברית ";
18891897 /// assert!(Some('ת') == s.trim_right().chars().rev().next());
18901898 /// ```
1899+ #[ must_use = "this returns the trimmed string as a new slice, \
1900+ without modifying the original"]
18911901 #[ inline]
18921902 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18931903 #[ rustc_deprecated(
@@ -2352,6 +2362,8 @@ impl str {
23522362 /// ```
23532363 /// assert_eq!("❤\n!".escape_debug().to_string(), "❤\\n!");
23542364 /// ```
2365+ #[ must_use = "this returns the escaped string as an iterator, \
2366+ without modifying the original"]
23552367 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
23562368 pub fn escape_debug ( & self ) -> EscapeDebug < ' _ > {
23572369 let mut chars = self . chars ( ) ;
@@ -2396,6 +2408,8 @@ impl str {
23962408 /// ```
23972409 /// assert_eq!("❤\n!".escape_default().to_string(), "\\u{2764}\\n!");
23982410 /// ```
2411+ #[ must_use = "this returns the escaped string as an iterator, \
2412+ without modifying the original"]
23992413 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
24002414 pub fn escape_default ( & self ) -> EscapeDefault < ' _ > {
24012415 EscapeDefault { inner : self . chars ( ) . flat_map ( CharEscapeDefault ) }
@@ -2432,6 +2446,8 @@ impl str {
24322446 /// ```
24332447 /// assert_eq!("❤\n!".escape_unicode().to_string(), "\\u{2764}\\u{a}\\u{21}");
24342448 /// ```
2449+ #[ must_use = "this returns the escaped string as an iterator, \
2450+ without modifying the original"]
24352451 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
24362452 pub fn escape_unicode ( & self ) -> EscapeUnicode < ' _ > {
24372453 EscapeUnicode { inner : self . chars ( ) . flat_map ( CharEscapeUnicode ) }
0 commit comments