Skip to content

Commit dba8e89

Browse files
committed
Add note about str::split handling of no matches.
resolves #142734
1 parent 5b74275 commit dba8e89

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/core/src/str/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,9 @@ impl str {
14951495
/// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
14961496
/// function or closure that determines if a character matches.
14971497
///
1498+
/// If there are no matches the full string slice is returned as the only
1499+
/// item in the iterator.
1500+
///
14981501
/// [`char`]: prim@char
14991502
/// [pattern]: self::pattern
15001503
///
@@ -1526,6 +1529,9 @@ impl str {
15261529
/// let v: Vec<&str> = "lion::tiger::leopard".split("::").collect();
15271530
/// assert_eq!(v, ["lion", "tiger", "leopard"]);
15281531
///
1532+
/// let v: Vec<&str> = "AABBCC".split("DD").collect();
1533+
/// assert_eq!(v, ["AABBCC"]);
1534+
///
15291535
/// let v: Vec<&str> = "abc1def2ghi".split(char::is_numeric).collect();
15301536
/// assert_eq!(v, ["abc", "def", "ghi"]);
15311537
///

0 commit comments

Comments
 (0)