]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/str/mod.rs
Document split{_ascii,}_whitespace() for empty strings
[rust.git] / library / core / src / str / mod.rs
index f673aa2a44b1023ee612a5e355ad4bbc59e25074..c0167388713388d7f1e4adbd00c54962eb5a7958 100644 (file)
@@ -902,6 +902,12 @@ pub fn bytes(&self) -> Bytes<'_> {
     ///
     /// assert_eq!(None, iter.next());
     /// ```
+    ///
+    /// If the string is empty or all whitespace, the iterator yields no string slices:
+    /// ```
+    /// assert_eq!("".split_whitespace().next(), None);
+    /// assert_eq!("   ".split_whitespace().next(), None);
+    /// ```
     #[must_use = "this returns the split string as an iterator, \
                   without modifying the original"]
     #[stable(feature = "split_whitespace", since = "1.1.0")]
@@ -946,6 +952,12 @@ pub fn split_whitespace(&self) -> SplitWhitespace<'_> {
     ///
     /// assert_eq!(None, iter.next());
     /// ```
+    ///
+    /// If the string is empty or all ASCII whitespace, the iterator yields no string slices:
+    /// ```
+    /// assert_eq!("".split_ascii_whitespace().next(), None);
+    /// assert_eq!("   ".split_ascii_whitespace().next(), None);
+    /// ```
     #[must_use = "this returns the split string as an iterator, \
                   without modifying the original"]
     #[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
@@ -2642,5 +2654,4 @@ struct UnsafeBytesToStr impl<'a> Fn = |bytes: &'a [u8]| -> &'a str {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-#[cfg(not(bootstrap))]
 impl !crate::error::Error for &str {}