diff options
author | Paul Masurel <paul.masurel@gmail.com> | 2017-04-04 22:43:35 +0900 |
---|---|---|
committer | Paul Masurel <paul.masurel@gmail.com> | 2017-04-04 22:43:35 +0900 |
commit | e0a39fb273d4db03a637dec31f040971468ff9ff (patch) | |
tree | cb01f9aca9c9a7557675fa56b0149ffe97e15274 /src/common/mod.rs | |
parent | 35203378ef0981d24e5ccd1b73e22c97a06580bc (diff) |
issue/96 Added unit test, documentation and various tiny improvements.
Diffstat (limited to 'src/common/mod.rs')
-rw-r--r-- | src/common/mod.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs index d2d41ce..c99c37f 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -3,16 +3,15 @@ mod timer; mod vint; pub mod bitpacker; - pub use self::serialize::BinarySerializable; pub use self::timer::Timing; pub use self::timer::TimerTree; pub use self::timer::OpenTimer; pub use self::vint::VInt; - use std::io; +/// Create a default io error given a string. pub fn make_io_err(msg: String) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) } @@ -30,7 +29,11 @@ pub trait HasLen { } -pub fn create_vec_with_len<T>(capacity: usize) -> Vec<T> { +/// Creates an uninitialized Vec of a given usize +/// +/// `allocate_vec` does an unsafe call to `set_len` +/// as other solution are extremely slow in debug mode. +pub fn allocate_vec<T>(capacity: usize) -> Vec<T> { let mut v = Vec::with_capacity(capacity); unsafe { v.set_len(capacity); |