Skip to content

Commit

Permalink
Document split{_ascii,}_whitespace() for empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechkral committed Nov 23, 2022
1 parent 4e0d0d7 commit 9a2b955
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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_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_ascii_whitespace", since = "1.34.0")]
Expand Down

0 comments on commit 9a2b955

Please sign in to comment.