-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #41503 - frewsxcv:rollup, r=frewsxcv
- Loading branch information
Showing
9 changed files
with
452 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# `splice` | ||
|
||
The tracking issue for this feature is: [#32310] | ||
|
||
[#32310]: https://github.com/rust-lang/rust/issues/32310 | ||
|
||
------------------------ | ||
|
||
The `splice()` method on `Vec` and `String` allows you to replace a range | ||
of values in a vector or string with another range of values, and returns | ||
the replaced values. | ||
|
||
A simple example: | ||
|
||
```rust | ||
#![feature(splice)] | ||
let mut s = String::from("α is alpha, β is beta"); | ||
let beta_offset = s.find('β').unwrap_or(s.len()); | ||
|
||
// Replace the range up until the β from the string | ||
let t: String = s.splice(..beta_offset, "Α is capital alpha; ").collect(); | ||
assert_eq!(t, "α is alpha, "); | ||
assert_eq!(s, "Α is capital alpha; β is beta"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.