Skip to content

Commit 0273f6f

Browse files
committed
Add a doctest example of str::split on a slice of chars
This is mentioned as supported, but the semantics are not described.
1 parent d37afad commit 0273f6f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/str/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,13 @@ impl str {
11311131
/// assert_eq!(v, ["lion", "tiger", "leopard"]);
11321132
/// ```
11331133
///
1134+
/// If the pattern is a slice of chars, split on each occurrence of any of the characters:
1135+
///
1136+
/// ```
1137+
/// let v: Vec<&str> = "2020-11-03 23:59".split(&['-', ' ', ':', '@'][..]).collect();
1138+
/// assert_eq!(v, ["2020", "11", "03", "23", "59"]);
1139+
/// ```
1140+
///
11341141
/// A more complex pattern, using a closure:
11351142
///
11361143
/// ```

0 commit comments

Comments
 (0)