about summary refs log tree commit diff
diff options
context:
space:
mode:
authorValdemar Erk <valdemar@erk.dev>2025-06-20 11:59:05 +0200
committerValdemar Erk <valdemar@erk.dev>2025-06-20 13:59:19 +0200
commit0be168e93eafa7c8d2baf7e9163e2126859100eb (patch)
tree2ee506641c046db8bc05f96a9af587f6dd1ecda3
parent5b74275f89b6041bf2e9dc2abcf332e206d4cfca (diff)
downloadrust-0be168e93eafa7c8d2baf7e9163e2126859100eb.tar.gz
rust-0be168e93eafa7c8d2baf7e9163e2126859100eb.zip
Add note about `str::split` handling of no matches.
-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 41834793d22..5c8d84f5c12 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"]);
     ///