File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 23
23
// * The `raw` and `bytes` submodules.
24
24
// * Boilerplate trait implementations.
25
25
26
- use crate :: borrow:: Borrow ;
27
26
use crate :: cmp;
28
27
use crate :: cmp:: Ordering :: { self , Equal , Greater , Less } ;
29
28
use crate :: fmt;
@@ -2157,14 +2156,16 @@ impl<T> [T] {
2157
2156
/// assert_eq!(buf, vec![1; 10]);
2158
2157
/// ```
2159
2158
#[ unstable( feature = "slice_fill" , issue = "70758" ) ]
2160
- pub fn fill < V > ( & mut self , value : V )
2159
+ pub fn fill ( & mut self , value : T )
2161
2160
where
2162
- V : Borrow < T > ,
2163
2161
T : Clone ,
2164
2162
{
2165
- let value = value. borrow ( ) ;
2166
- for el in self {
2167
- el. clone_from ( value)
2163
+ if let Some ( ( last, elems) ) = self . split_last_mut ( ) {
2164
+ for el in elems {
2165
+ el. clone_from ( & value) ;
2166
+ }
2167
+
2168
+ * last = value
2168
2169
}
2169
2170
}
2170
2171
You can’t perform that action at this time.
0 commit comments