From 498d0f1354af8c32fa15f955199dbac8b51fc4e3 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 20 Jun 2017 15:12:30 -0700 Subject: [PATCH 1/5] Use liballoc instead of libcollections in no_std mode libcollections was deprecated in rust-lang/rust#42648 and its contents were moved to liballoc. --- Cargo.toml | 1 - lib.rs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f928008..5c7ed9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ documentation = "http://doc.servo.org/smallvec/" [features] heapsizeof = ["heapsize", "std"] -collections = [] std = [] default = ["std"] diff --git a/lib.rs b/lib.rs index ccd32fb..4b4f435 100644 --- a/lib.rs +++ b/lib.rs @@ -7,14 +7,14 @@ //! locality and reducing allocator traffic for workloads that fit within the inline buffer. #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(collections))] +#![cfg_attr(not(feature = "std"), feature(alloc))] #[cfg(not(feature = "std"))] -extern crate collections; +extern crate alloc; #[cfg(not(feature = "std"))] -use collections::Vec; +use alloc::Vec; #[cfg(feature="heapsizeof")] extern crate heapsize; From 47cbda7705fbcb0273e31af605896b7af22aa1c3 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 20 Jun 2017 15:21:22 -0700 Subject: [PATCH 2/5] Make tests work without libstd --- .travis.yml | 1 + lib.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8a946c3..81f8bd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ script: | cargo build --features=heapsizeof --verbose && cargo test --verbose && cargo test --features=heapsizeof --verbose && + ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features) && ([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench) notifications: webhooks: http://build.servo.org:54856/travis diff --git a/lib.rs b/lib.rs index 4b4f435..cb48efc 100644 --- a/lib.rs +++ b/lib.rs @@ -11,6 +11,7 @@ #[cfg(not(feature = "std"))] +#[cfg_attr(test, macro_use)] extern crate alloc; #[cfg(not(feature = "std"))] @@ -967,9 +968,18 @@ impl_array!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 3 #[cfg(test)] pub mod tests { use SmallVec; - use std::borrow::ToOwned; + use std::iter::FromIterator; + #[cfg(feature = "std")] + use std::borrow::ToOwned; + #[cfg(not(feature = "std"))] + use alloc::borrow::ToOwned; + #[cfg(not(feature = "std"))] + use alloc::boxed::Box; + #[cfg(not(feature = "std"))] + use alloc::vec::Vec; + #[cfg(feature="heapsizeof")] use heapsize::HeapSizeOf; #[cfg(feature="heapsizeof")] @@ -1311,6 +1321,7 @@ pub mod tests { assert!(c > b); } + #[cfg(feature = "std")] #[test] fn test_hash() { use std::hash::Hash; From ae5b61591ce8ef65e1ba347790d9d9826606dc3f Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 20 Jun 2017 15:23:40 -0700 Subject: [PATCH 3/5] Point to docs.rs for documentation (because Servo isn't always using the latest version of this crate) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7211e0..8e00858 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ rust-smallvec ============= -[Documentation](http://doc.servo.org/smallvec/) +[Documentation](http://docs.rs/smallvec/) "Small vector" optimization for Rust: store up to a small number of items on the stack From f747b48e3a245631a068c0e69b360b5672f1ed90 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 20 Jun 2017 15:36:04 -0700 Subject: [PATCH 4/5] Document no_std support --- Cargo.toml | 2 +- lib.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5c7ed9d..5e1db3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Simon Sapin "] license = "MPL-2.0" repository = "https://github.com/servo/rust-smallvec" description = "'Small vector' optimization: store up to a small number of items on the stack" -keywords = ["small", "vec", "vector", "stack"] +keywords = ["small", "vec", "vector", "stack", "no_std"] readme = "README.md" documentation = "http://doc.servo.org/smallvec/" diff --git a/lib.rs b/lib.rs index cb48efc..96604f8 100644 --- a/lib.rs +++ b/lib.rs @@ -5,6 +5,15 @@ //! Small vectors in various sizes. These store a certain number of elements inline, and fall back //! to the heap for larger allocations. This can be a useful optimization for improving cache //! locality and reducing allocator traffic for workloads that fit within the inline buffer. +//! +//! ## no_std support +//! +//! By default, `smallvec` depends on `libstd`. However, it can be configured to use the unstable +//! `liballoc` API instead, for use on platforms that have `liballoc` but not `libstd`. This +//! configuration is currently unstable and is not guaranteed to work on all versions of Rust. +//! +//! To depend on `smallvec` without `libstd`, use `default-features = false` in the `smallvec` +//! section of Cargo.toml to disable its `"std"` feature. #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(alloc))] From bf9ac18e48696ee7e967fd77a3ebff5f08db2d34 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 20 Jun 2017 15:38:54 -0700 Subject: [PATCH 5/5] Release version 0.4.1 New features: * `no_std` support (#49). * `SmallVec<[u8; N]>` implements the `Write` trait (#52). * Add an `ExtendFromSlice` trait for both `Vec` and `SmallVec` (#54). --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5e1db3d..5516116 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smallvec" -version = "0.4.0" +version = "0.4.1" authors = ["Simon Sapin "] license = "MPL-2.0" repository = "https://github.com/servo/rust-smallvec"