Auto merge of #53 - mbrubeck:no_std, r=emilio

Document and test no_std support

This builds on the new "std" Cargo feature added in #49.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/53)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo
2017-06-28 18:05:26 -07:00
committed by GitHub
4 changed files with 28 additions and 8 deletions
+1
View File
@@ -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
+2 -3
View File
@@ -1,17 +1,16 @@
[package]
name = "smallvec"
version = "0.4.0"
version = "0.4.1"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
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/"
[features]
heapsizeof = ["heapsize", "std"]
collections = []
std = []
default = ["std"]
+1 -1
View File
@@ -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
+24 -4
View File
@@ -5,16 +5,26 @@
//! 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(collections))]
#![cfg_attr(not(feature = "std"), feature(alloc))]
#[cfg(not(feature = "std"))]
extern crate collections;
#[cfg_attr(test, macro_use)]
extern crate alloc;
#[cfg(not(feature = "std"))]
use collections::Vec;
use alloc::Vec;
#[cfg(feature="heapsizeof")]
extern crate heapsize;
@@ -967,9 +977,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 +1330,7 @@ pub mod tests {
assert!(c > b);
}
#[cfg(feature = "std")]
#[test]
fn test_hash() {
use std::hash::Hash;