Skip to content

Commit

Permalink
Rollup merge of #81048 - yoshuawuyts:stabilize-core-slice-fill-with, …
Browse files Browse the repository at this point in the history
…r=m-ou-se

Stabilize `core::slice::fill_with`

_Tracking issue: https://github.com/rust-lang/rust/issues/79221_

This stabilizes the `slice_fill_with` feature for Rust 1.51, following the stabilization of `slice_fill` in 1.50. This was requested by libs team members in #79213.

This PR also adds the "memset" alias for `slice::fill_with`, mirroring the alias set on the `slice::fill` sibling API. This will ensure someone looking for "memset" will find both variants.

r? `@Amanieu`
  • Loading branch information
jonas-schievink authored Jan 31, 2021
2 parents caf2c06 + b50df6d commit 0793fab
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2852,13 +2852,12 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(slice_fill_with)]
///
/// let mut buf = vec![1; 10];
/// buf.fill_with(Default::default);
/// assert_eq!(buf, vec![0; 10]);
/// ```
#[unstable(feature = "slice_fill_with", issue = "79221")]
#[doc(alias = "memset")]
#[stable(feature = "slice_fill_with", since = "1.51.0")]
pub fn fill_with<F>(&mut self, mut f: F)
where
F: FnMut() -> T,
Expand Down

0 comments on commit 0793fab

Please sign in to comment.