let mut vec = Vec::with_capacity(10); for i in 0..10 { vec.push(i); }
🔍 #Rustlang Tip: Use Vec::with_capacity(n) when you know the approximate size of your vector beforehand. This will reserve memory for the vector to avoid multiple allocations.
Be careful though, if you overestimate the size of the vector you will waste memory!
#RustCollections #Rust30by30 #Day16
0
0
0
0