2021-02-07 23:01:02 -06:00
|
|
|
pub(super) trait SpecFill<T> {
|
|
|
|
fn spec_fill(&mut self, value: T);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Clone> SpecFill<T> for [T] {
|
|
|
|
default fn spec_fill(&mut self, value: T) {
|
|
|
|
if let Some((last, elems)) = self.split_last_mut() {
|
|
|
|
for el in elems {
|
|
|
|
el.clone_from(&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
*last = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Copy> SpecFill<T> for [T] {
|
2021-03-17 17:45:03 -05:00
|
|
|
fn spec_fill(&mut self, value: T) {
|
2021-08-09 12:25:28 -05:00
|
|
|
for item in self.iter_mut() {
|
|
|
|
*item = value;
|
2021-02-07 23:01:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|