MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / seq_resize_and_fill

Function seq_resize_and_fill

splashsurf_lib/src/utils.rs:84–90  ·  view source on GitHub ↗
(vec: &mut Vec<T>, new_len: usize, value: T)

Source from the content-addressed store, hash-verified

82/// Resizes the given vector to the given length and fills new entries with `value.clone()`, sequential version
83#[allow(unused)]
84pub(crate) fn seq_resize_and_fill<T: Clone>(vec: &mut Vec<T>, new_len: usize, value: T) {
85 let old_len = vec.len();
86 vec.iter_mut()
87 .take(old_len.min(new_len))
88 .for_each(|v| *v = value.clone());
89 vec.resize(new_len, value);
90}
91
92/// Resizes the given vector to the given length and fills new entries with `value.clone()`, parallel version
93#[allow(unused)]

Callers 1

resize_and_fillFunction · 0.85

Calls 5

for_eachMethod · 0.80
iter_mutMethod · 0.80
cloneMethod · 0.80
lenMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected