Skip to content

Commit

Permalink
Rollup merge of #71165 - lcnr:patch-2, r=Amanieu
Browse files Browse the repository at this point in the history
`slice::fill`: use `T` instead of generic arg

implements #70758 (comment)

As the discussion in #70758 has shifted, I now use `T` instead of `&T`.
  • Loading branch information
Dylan-DPC committed May 3, 2020
2 parents 0a675c5 + 902aa62 commit 8cb8d9c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// * The `raw` and `bytes` submodules.
// * Boilerplate trait implementations.

use crate::borrow::Borrow;
use crate::cmp;
use crate::cmp::Ordering::{self, Equal, Greater, Less};
use crate::fmt;
Expand Down Expand Up @@ -2157,14 +2156,16 @@ impl<T> [T] {
/// assert_eq!(buf, vec![1; 10]);
/// ```
#[unstable(feature = "slice_fill", issue = "70758")]
pub fn fill<V>(&mut self, value: V)
pub fn fill(&mut self, value: T)
where
V: Borrow<T>,
T: Clone,
{
let value = value.borrow();
for el in self {
el.clone_from(value)
if let Some((last, elems)) = self.split_last_mut() {
for el in elems {
el.clone_from(&value);
}

*last = value
}
}

Expand Down

0 comments on commit 8cb8d9c

Please sign in to comment.