Add a doctest example of str::split on a slice of chars

This is mentioned as supported, but the semantics are not described.
This commit is contained in:
Martin Pool 2020-12-02 08:50:17 -08:00
parent d37afad0cc
commit 0273f6f849

View file

@ -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:
///
/// ```