Rust vector reduce size

阅读量: searchstar 2022-08-26 22:11:13
Categories: Tags:

resize requires a default value:

fn resize(&mut self, new_len: usize, value: T)

While truncate does not:

fn truncate(&mut self, len: usize)

If len is greater than the vector's current length, truncate has no effect.

Document: https://static.rust-lang.org/doc/master/std/vec/struct.Vec.html