Skip to content
/ rust Public
forked from rust-lang/rust

Commit bce9b14

Browse files
budziqdtolnay
authored andcommitted
stabilized vec_splice (fixes rust-lang#32310)
1 parent 00cd2d6 commit bce9b14

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/doc/unstable-book/src/library-features/splice.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ The tracking issue for this feature is: [#32310]
66

77
------------------------
88

9-
The `splice()` method on `Vec` and `String` allows you to replace a range
10-
of values in a vector or string with another range of values, and returns
9+
The `splice()` method on `String` allows you to replace a range
10+
of values in a string with another range of values, and returns
1111
the replaced values.
1212

1313
A simple example:
@@ -21,4 +21,4 @@ let beta_offset = s.find('β').unwrap_or(s.len());
2121
let t: String = s.splice(..beta_offset, "Α is capital alpha; ").collect();
2222
assert_eq!(t, "α is alpha, ");
2323
assert_eq!(s, "Α is capital alpha; β is beta");
24-
```
24+
```

src/liballoc/vec.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1942,15 +1942,14 @@ impl<T> Vec<T> {
19421942
/// # Examples
19431943
///
19441944
/// ```
1945-
/// #![feature(splice)]
19461945
/// let mut v = vec![1, 2, 3];
19471946
/// let new = [7, 8];
19481947
/// let u: Vec<_> = v.splice(..2, new.iter().cloned()).collect();
19491948
/// assert_eq!(v, &[7, 8, 3]);
19501949
/// assert_eq!(u, &[1, 2]);
19511950
/// ```
19521951
#[inline]
1953-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
1952+
#[stable(feature = "vec_splice", since = "1.22.0")]
19541953
pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<I::IntoIter>
19551954
where R: RangeArgument<usize>, I: IntoIterator<Item=T>
19561955
{
@@ -2550,13 +2549,13 @@ impl<'a, T> InPlace<T> for PlaceBack<'a, T> {
25502549
/// [`splice()`]: struct.Vec.html#method.splice
25512550
/// [`Vec`]: struct.Vec.html
25522551
#[derive(Debug)]
2553-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
2552+
#[stable(feature = "vec_splice", since = "1.22.0")]
25542553
pub struct Splice<'a, I: Iterator + 'a> {
25552554
drain: Drain<'a, I::Item>,
25562555
replace_with: I,
25572556
}
25582557

2559-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
2558+
#[stable(feature = "vec_splice", since = "1.22.0")]
25602559
impl<'a, I: Iterator> Iterator for Splice<'a, I> {
25612560
type Item = I::Item;
25622561

@@ -2569,18 +2568,18 @@ impl<'a, I: Iterator> Iterator for Splice<'a, I> {
25692568
}
25702569
}
25712570

2572-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
2571+
#[stable(feature = "vec_splice", since = "1.22.0")]
25732572
impl<'a, I: Iterator> DoubleEndedIterator for Splice<'a, I> {
25742573
fn next_back(&mut self) -> Option<Self::Item> {
25752574
self.drain.next_back()
25762575
}
25772576
}
25782577

2579-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
2578+
#[stable(feature = "vec_splice", since = "1.22.0")]
25802579
impl<'a, I: Iterator> ExactSizeIterator for Splice<'a, I> {}
25812580

25822581

2583-
#[unstable(feature = "splice", reason = "recently added", issue = "32310")]
2582+
#[stable(feature = "vec_splice", since = "1.22.0")]
25842583
impl<'a, I: Iterator> Drop for Splice<'a, I> {
25852584
fn drop(&mut self) {
25862585
// exhaust drain first

0 commit comments

Comments
 (0)