mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-01 15:50:05 +03:00
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
This commit is contained in:
@@ -1495,6 +1495,9 @@ pub fn rfind<P: Pattern>(&self, pat: P) -> Option<usize>
|
||||
/// 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 @@ pub fn rfind<P: Pattern>(&self, pat: P) -> Option<usize>
|
||||
/// 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"]);
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user