From 47d33b170cac9b20d45107d8374f0441293ca143 Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Sat, 20 May 2017 11:29:55 -0700 Subject: [PATCH] Add no_std support --- Cargo.toml | 5 ++++- lib.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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;