News for hackers. Stuff that matters.
Re:Effective Rust by tveita on Thursday June 15, 2023 @08:14AM (#36339360)
From https://doc.rust-lang.org/std/vec/struct.Vec.html

  if you construct a Vec with capacity 0 via Vec::new, vec![], Vec::with_capacity(0), or by calling shrink_to_fit on an empty Vec, it will not allocate memory.
So an empty vec![] is just a struct on the stack; very cheap to make, and easy for the compiler to optimize out if it can see that it's not used in some paths.

There are no comments on this comment yet.