about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.pm>2022-11-23 15:36:51 +0100
committerVojtech Kral <vojtech@kral.pm>2022-11-24 15:22:24 +0100
commit07ccf67f59d08bcc12705121fbbed3f844b9689c (patch)
tree42477e44323b407e29e5eed5c51e720f5ff7b07b
parent4e0d0d757e2f1b61ec809420b006545a9f8974c0 (diff)
downloadrust-07ccf67f59d08bcc12705121fbbed3f844b9689c.tar.gz
rust-07ccf67f59d08bcc12705121fbbed3f844b9689c.zip
Document split{_ascii,}_whitespace() for empty strings
-rw-r--r--library/core/src/str/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index fbc0fc397a5..c0167388713 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -902,6 +902,12 @@ impl str {
     ///
     /// 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 @@ impl str {
     ///
     /// 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")]