Auto merge of #49 - Pratyush:master, r=mbrubeck

Add no_std support

This library can easily support `no_std` code on `nightly`; it does require the `collections` feature, however. This PR adds support for this feature by enabling a on-by-default `std` feature. This feature can be turned off to support `no_std` mode.

<!-- 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/49)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo
2017-06-20 15:09:37 -07:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -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"
+15
View File
@@ -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;