diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-04 11:07:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-04 11:07:20 +0200 |
| commit | 29ab7d8db02b63464963905612b59a8f745bd2b6 (patch) | |
| tree | c3f9a4d69c6e9952d21b66a756a34342249eb2a0 /src/liballoc/string.rs | |
| parent | 7dad49f9069b1678aa92959984f9c947308473da (diff) | |
| parent | e75c6a741eded857b2ab06b63ebd3848d9203343 (diff) | |
Rollup merge of #49577 - tmccombs:string-splice-stabilize, r=TimNN
Stabilize String::replace_range Fixes #44643
Diffstat (limited to 'src/liballoc/string.rs')
| -rw-r--r-- | src/liballoc/string.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index aa202e23628..b95aae02894 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1517,7 +1517,7 @@ impl String { } } - /// Creates a splicing iterator that removes the specified range in the string, + /// Removes the specified range in the string, /// and replaces it with the given string. /// The given string doesn't need to be the same length as the range. /// @@ -1537,21 +1537,20 @@ impl String { /// Basic usage: /// /// ``` - /// #![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 - /// s.splice(..beta_offset, "Α is capital alpha; "); + /// s.replace_range(..beta_offset, "Α is capital alpha; "); /// assert_eq!(s, "Α is capital alpha; β is beta"); /// ``` - #[unstable(feature = "splice", reason = "recently added", issue = "44643")] - pub fn splice<R>(&mut self, range: R, replace_with: &str) + #[stable(feature = "splice", since = "1.27.0")] + pub fn replace_range<R>(&mut self, range: R, replace_with: &str) where R: RangeBounds<usize> { // Memory safety // - // The String version of Splice does not have the memory safety issues + // Replace_range does not have the memory safety issues of a vector Splice. // of the vector version. The data is just plain bytes. match range.start() { |
