From 697ec9fb89a337e17ba45a95d8c0c246b0b627a6 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 23 Aug 2016 23:58:07 +0200 Subject: [PATCH] add proper smallvec support --- Cargo.toml | 4 ++-- src/lib.rs | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2bdb4d7..54a6cd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "insert_many" -version = "0.1.0" +version = "0.1.1" authors = ["Robert Habermeier "] description = "insert_many optimization for vec-like structures" license = "MIT" @@ -10,4 +10,4 @@ repository = "https://github.com/rphmeier/insert_many.git" smallvec = { version = "0.2.0", optional = true } [features] -default = ["smallvec"] \ No newline at end of file +default = ["smallvec"] diff --git a/src/lib.rs b/src/lib.rs index 89b817f..e185eb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,12 +2,14 @@ //! Like `Vec::insert`, but inserts a series of items at an index rather than a single one. //! This can lead to significant speedup where multiple items need to be inserted. -#[cfg(features = "smallvec")] +#[cfg(feature = "smallvec")] extern crate smallvec; use std::iter::ExactSizeIterator; use std::ptr; +use smallvec::SmallVec; + /// Generalized trait for inserting many items at once. pub trait InsertMany { /// Insert all the items in the given iterable at `index`, shifting all elements after it to the right. @@ -52,7 +54,7 @@ impl InsertMany for Vec { } } -#[cfg(features = "smallvec")] +#[cfg(feature = "smallvec")] impl InsertMany for SmallVec { fn insert_many(&mut self, index: usize, iterable: I) where I: IntoIterator, I::IntoIter: ExactSizeIterator { impl_veclike!(self, index, iterable); @@ -80,4 +82,4 @@ mod tests { assert_eq!(v, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]); } -} \ No newline at end of file +}