about summary refs log tree commit diff
path: root/library/core/src/str/mod.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-06-24 11:20:08 +0200
committerGitHub <noreply@github.com>2025-06-24 11:20:08 +0200
commit673ce2a6c99fd8d1fa205fa73fc2f3adee93a03a (patch)
tree054f1cc07544cd1bd255eadd4b3fee5a977518a0 /library/core/src/str/mod.rs
parent69cc875438e06348c1f93090100067fe06404e8d (diff)
parent0be168e93eafa7c8d2baf7e9163e2126859100eb (diff)
downloadrust-673ce2a6c99fd8d1fa205fa73fc2f3adee93a03a.tar.gz
rust-673ce2a6c99fd8d1fa205fa73fc2f3adee93a03a.zip
Rollup merge of #142779 - Erk-:fix/core/142734, r=jhpratt
Add note about `str::split` handling of no matches.

Adds small note and example to the test for a non matching pattern

resolves rust-lang/rust#142734
Diffstat (limited to 'library/core/src/str/mod.rs')
-rw-r--r--library/core/src/str/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 5051b2288fd..d250e1478d8 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -1495,6 +1495,9 @@ impl str {
     /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
     /// function or closure that determines if a character matches.
     ///
+    /// If there are no matches the full string slice is returned as the only
+    /// item in the iterator.
+    ///
     /// [`char`]: prim@char
     /// [pattern]: self::pattern
     ///
@@ -1526,6 +1529,9 @@ impl str {
     /// let v: Vec<&str> = "lion::tiger::leopard".split("::").collect();
     /// assert_eq!(v, ["lion", "tiger", "leopard"]);
     ///
+    /// let v: Vec<&str> = "AABBCC".split("DD").collect();
+    /// assert_eq!(v, ["AABBCC"]);
+    ///
     /// let v: Vec<&str> = "abc1def2ghi".split(char::is_numeric).collect();
     /// assert_eq!(v, ["abc", "def", "ghi"]);
     ///