@@ -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 }
@@ -1840,6 +1846,8 @@ impl str {
18401846 /// let s = " עברית";
18411847 /// assert!(Some('ע') == s.trim_left().chars().next());
18421848 /// ```
1849+ #[ must_use = "this returns the trimmed string as a new slice, \
1850+ without modifying the original"]
18431851 #[ inline]
18441852 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18451853 #[ rustc_deprecated(
@@ -1882,6 +1890,8 @@ impl str {
18821890 /// let s = "עברית ";
18831891 /// assert!(Some('ת') == s.trim_right().chars().rev().next());
18841892 /// ```
1893+ #[ must_use = "this returns the trimmed string as a new slice, \
1894+ without modifying the original"]
18851895 #[ inline]
18861896 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18871897 #[ rustc_deprecated(
@@ -2346,6 +2356,8 @@ impl str {
23462356 /// ```
23472357 /// assert_eq!("❤\n!".escape_debug().to_string(), "❤\\n!");
23482358 /// ```
2359+ #[ must_use = "this returns the escaped string as an iterator, \
2360+ without modifying the original"]
23492361 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
23502362 pub fn escape_debug ( & self ) -> EscapeDebug < ' _ > {
23512363 let mut chars = self . chars ( ) ;
@@ -2390,6 +2402,8 @@ impl str {
23902402 /// ```
23912403 /// assert_eq!("❤\n!".escape_default().to_string(), "\\u{2764}\\n!");
23922404 /// ```
2405+ #[ must_use = "this returns the escaped string as an iterator, \
2406+ without modifying the original"]
23932407 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
23942408 pub fn escape_default ( & self ) -> EscapeDefault < ' _ > {
23952409 EscapeDefault { inner : self . chars ( ) . flat_map ( CharEscapeDefault ) }
@@ -2426,6 +2440,8 @@ impl str {
24262440 /// ```
24272441 /// assert_eq!("❤\n!".escape_unicode().to_string(), "\\u{2764}\\u{a}\\u{21}");
24282442 /// ```
2443+ #[ must_use = "this returns the escaped string as an iterator, \
2444+ without modifying the original"]
24292445 #[ stable( feature = "str_escape" , since = "1.34.0" ) ]
24302446 pub fn escape_unicode ( & self ) -> EscapeUnicode < ' _ > {
24312447 EscapeUnicode { inner : self . chars ( ) . flat_map ( CharEscapeUnicode ) }
0 commit comments