Skip to content

Commit 36db658

Browse files
authored
Rollup merge of #88707 - sylvestre:split_example, r=yaahc
String.split_terminator: Add an example when using a slice of chars
2 parents 910692d + d4031d0 commit 36db658

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/core/src/str/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,9 @@ impl str {
13531353
///
13541354
/// let v: Vec<&str> = "A..B..".split_terminator(".").collect();
13551355
/// assert_eq!(v, ["A", "", "B", ""]);
1356+
///
1357+
/// let v: Vec<&str> = "A.B:C.D".split_terminator(&['.', ':'][..]).collect();
1358+
/// assert_eq!(v, ["A", "B", "C", "D"]);
13561359
/// ```
13571360
#[stable(feature = "rust1", since = "1.0.0")]
13581361
#[inline]
@@ -1396,6 +1399,9 @@ impl str {
13961399
///
13971400
/// let v: Vec<&str> = "A..B..".rsplit_terminator(".").collect();
13981401
/// assert_eq!(v, ["", "B", "", "A"]);
1402+
///
1403+
/// let v: Vec<&str> = "A.B:C.D".rsplit_terminator(&['.', ':'][..]).collect();
1404+
/// assert_eq!(v, ["D", "C", "B", "A"]);
13991405
/// ```
14001406
#[stable(feature = "rust1", since = "1.0.0")]
14011407
#[inline]

0 commit comments

Comments
 (0)