Skip to content

Commit

Permalink
Auto merge of rust-lang#79641 - sourcefrog:split-example, r=dtolnay
Browse files Browse the repository at this point in the history
Add a doctest example of str::split on a slice of chars

This is mentioned as supported, but the semantics are not described.
  • Loading branch information
bors committed Dec 7, 2020
2 parents f00ace9 + 0273f6f commit e5721a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,13 @@ impl str {
/// assert_eq!(v, ["lion", "tiger", "leopard"]);
/// ```
///
/// If the pattern is a slice of chars, split on each occurrence of any of the characters:
///
/// ```
/// let v: Vec<&str> = "2020-11-03 23:59".split(&['-', ' ', ':', '@'][..]).collect();
/// assert_eq!(v, ["2020", "11", "03", "23", "59"]);
/// ```
///
/// A more complex pattern, using a closure:
///
/// ```
Expand Down

0 comments on commit e5721a5

Please sign in to comment.