diff --git a/Cargo.toml b/Cargo.toml index 2a64c04..991ab23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,10 @@ readme = "README.md" documentation = "http://doc.servo.org/smallvec/" [features] -heapsizeof = ["heapsize"] +heapsizeof = ["heapsize", "std"] +collections = [] +std = [] +default = ["std"] [lib] name = "smallvec" diff --git a/lib.rs b/lib.rs index f03108a..7b4243e 100644 --- a/lib.rs +++ b/lib.rs @@ -6,9 +6,24 @@ //! 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. +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(feature = "std"), feature(collections))] + + +#[cfg(not(feature = "std"))] +extern crate collections; + +#[cfg(not(feature = "std"))] +use collections::Vec; + #[cfg(feature="heapsizeof")] extern crate heapsize; +#[cfg(not(feature = "std"))] +mod std { + pub use core::*; +} + use std::borrow::{Borrow, BorrowMut}; use std::cmp; use std::fmt;