Closed
Description
When pushing the same item to vec.
fn gen_portions() -> Vec<Vec<u8>> {
let mut spaces = Vec::with_capacity(EMPTY_SPACES_COUNT);
for _ in 0..EMPTY_SPACES_COUNT {
spaces.push(vec![b' ']);
}
spaces
}
Could be.
fn gen_portions() -> Vec<Vec<u8>> {
let mut spaces = Vec::with_capacity(EMPTY_SPACES_COUNT);
spaces.resize(EMPTY_SPACES_COUNT, vec![b' ']);
spaces
}
Maybe we could even use vec![b''].repeat(EMPTY_SPACES_COUNT)
after stabilization ofrepeat_generic_size
? rust-lang/rust#48784