From 0273f6f849270a798761e056382f859063c69e21 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 2 Dec 2020 08:50:17 -0800 Subject: [PATCH] Add a doctest example of str::split on a slice of chars This is mentioned as supported, but the semantics are not described. --- library/core/src/str/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index a944514f694..83cf47c8c8f 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -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: /// /// ```