mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
auto merge of #14335 : tbu-/rust/pr_doc_strsplit, r=pnkfelix
In particular, show examples for splitting the empty string and using `splitn` with a count of 0. Fix #14222.
This commit is contained in:
commit
9ac9148bbd
@ -1112,6 +1112,9 @@ pub trait StrSlice<'a> {
|
||||
///
|
||||
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
|
||||
/// assert_eq!(v, vec!["lion", "", "tiger", "leopard"]);
|
||||
///
|
||||
/// let v: Vec<&str> = "".split('X').collect();
|
||||
/// assert_eq!(v, vec![""]);
|
||||
/// ```
|
||||
fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplits<'a, Sep>;
|
||||
|
||||
@ -1130,6 +1133,12 @@ pub trait StrSlice<'a> {
|
||||
///
|
||||
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn('X', 2).collect();
|
||||
/// assert_eq!(v, vec!["lion", "", "tigerXleopard"]);
|
||||
///
|
||||
/// let v: Vec<&str> = "abcXdef".splitn('X', 0).collect();
|
||||
/// assert_eq!(v, vec!["abcXdef"]);
|
||||
///
|
||||
/// let v: Vec<&str> = "".splitn('X', 1).collect();
|
||||
/// assert_eq!(v, vec![""]);
|
||||
/// ```
|
||||
fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitsN<'a, Sep>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user