Method
resize_with
(
&mut self, new_len: usize, mut f: F,
)
Source from the content-addressed store, hash-verified
| 806 | /// ``` |
| 807 | #[inline] |
| 808 | pub fn resize_with<F: FnMut() -> A::Item>( |
| 809 | &mut self, new_len: usize, mut f: F, |
| 810 | ) { |
| 811 | match new_len.checked_sub(self.len as usize) { |
| 812 | None => self.truncate(new_len), |
| 813 | Some(new_elements) => { |
| 814 | for _ in 0..new_elements { |
| 815 | self.push(f()); |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | /// Walk the vec and keep only the elements that pass the predicate given. |
| 822 | /// |
Tested by
no test coverage detected