1pub(super) trait SpecFill<T> {
2 fn spec_fill(&mut self, value: T);
3}
4
5impl<T: Clone> SpecFill<T> for [T] {
6 default fn spec_fill(&mut self, value: T) {
7 if let Some((last: &mut T, elems: &mut [T])) = self.split_last_mut() {
8 for el: &mut T in elems {
9 el.clone_from(&value);
10 }
11
12 *last = value
13 }
14 }
15}
16
17impl<T: Copy> SpecFill<T> for [T] {
18 fn spec_fill(&mut self, value: T) {
19 for item: &mut T in self.iter_mut() {
20 *item = value;
21 }
22 }
23}
24