Last active
December 16, 2015 18:09
-
-
Save JohnMurray/5476038 to your computer and use it in GitHub Desktop.
Question for Rust IRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Question: should this be the correct way to initialize a new vector | |
* with a set capacity? Seems al little verbose. | |
*/ | |
fn main() -> () { | |
let mut a : ~[int] = ~[]; | |
vec::reserve(&mut a, 20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So to make this complete for anyone else who looks,
Jeaye
from the Mozilla Rust IRC suggested usingvec::with_capacity
such that: