diff options
Diffstat (limited to 'src/common/mod.rs')
-rw-r--r-- | src/common/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs index 0ab876a..d2d41ce 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -30,3 +30,10 @@ pub trait HasLen { } +pub fn create_vec_with_len<T>(capacity: usize) -> Vec<T> { + let mut v = Vec::with_capacity(capacity); + unsafe { + v.set_len(capacity); + } + v +}
\ No newline at end of file |