rust-vector-reduce-size

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

posted @ 2024-09-28 13:45  寻找繁星  阅读(1)  评论(0编辑  收藏  举报