Skip to content

Commit

Permalink
Auto merge of rust-lang#77850 - kornelski:resizedefault, r=dtolnay
Browse files Browse the repository at this point in the history
Remove deprecated unstable Vec::resize_default

It's [been deprecated](rust-lang#57656) for 15 releases.
  • Loading branch information
bors committed Oct 16, 2020
2 parents 6999ff3 + 07637db commit 8850893
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,50 +1603,6 @@ impl<T: Clone> Vec<T> {
}
}

impl<T: Default> Vec<T> {
/// Resizes the `Vec` in-place so that `len` is equal to `new_len`.
///
/// If `new_len` is greater than `len`, the `Vec` is extended by the
/// difference, with each additional slot filled with [`Default::default()`].
/// If `new_len` is less than `len`, the `Vec` is simply truncated.
///
/// This method uses [`Default`] to create new values on every push. If
/// you'd rather [`Clone`] a given value, use [`resize`].
///
/// # Examples
///
/// ```
/// # #![allow(deprecated)]
/// #![feature(vec_resize_default)]
///
/// let mut vec = vec![1, 2, 3];
/// vec.resize_default(5);
/// assert_eq!(vec, [1, 2, 3, 0, 0]);
///
/// let mut vec = vec![1, 2, 3, 4];
/// vec.resize_default(2);
/// assert_eq!(vec, [1, 2]);
/// ```
///
/// [`resize`]: Vec::resize
#[unstable(feature = "vec_resize_default", issue = "41758")]
#[rustc_deprecated(
reason = "This is moving towards being removed in favor \
of `.resize_with(Default::default)`. If you disagree, please comment \
in the tracking issue.",
since = "1.33.0"
)]
pub fn resize_default(&mut self, new_len: usize) {
let len = self.len();

if new_len > len {
self.extend_with(new_len - len, ExtendDefault);
} else {
self.truncate(new_len);
}
}
}

// This code generalizes `extend_with_{element,default}`.
trait ExtendWith<T> {
fn next(&mut self) -> T;
Expand Down

0 comments on commit 8850893

Please sign in to comment.