Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: