MCPcopy Create free account
hub / github.com/Lokathor/tinyvec / resize_with

Method resize_with

src/arrayvec.rs:808–819  ·  view source on GitHub ↗
(
    &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 ///

Callers 1

resizeMethod · 0.45

Calls 2

truncateMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected