diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-09 11:55:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-09 11:55:58 +0200 |
| commit | 36db65879652ddd69a20f8939611ff4201318947 (patch) | |
| tree | 8f4d282bc807df4f4f4a377cf2e507236b72e1b5 | |
| parent | 910692de742e9c0b1a57b7c5e467b8b85d903269 (diff) | |
| parent | d4031d092d0dcc3140af8fe0aa009cf98e701009 (diff) | |
| download | rust-36db65879652ddd69a20f8939611ff4201318947.tar.gz rust-36db65879652ddd69a20f8939611ff4201318947.zip | |
Rollup merge of #88707 - sylvestre:split_example, r=yaahc
String.split_terminator: Add an example when using a slice of chars
| -rw-r--r-- | library/core/src/str/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 607fb627605..769d85d0588 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1353,6 +1353,9 @@ impl str { /// /// let v: Vec<&str> = "A..B..".split_terminator(".").collect(); /// assert_eq!(v, ["A", "", "B", ""]); + /// + /// let v: Vec<&str> = "A.B:C.D".split_terminator(&['.', ':'][..]).collect(); + /// assert_eq!(v, ["A", "B", "C", "D"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -1396,6 +1399,9 @@ impl str { /// /// let v: Vec<&str> = "A..B..".rsplit_terminator(".").collect(); /// assert_eq!(v, ["", "B", "", "A"]); + /// + /// let v: Vec<&str> = "A.B:C.D".rsplit_terminator(&['.', ':'][..]).collect(); + /// assert_eq!(v, ["D", "C", "B", "A"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] |
