Skip to content

Commit

Permalink
Auto merge of #49 - Pratyush:master, r=mbrubeck
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo authored Jun 20, 2017
2 parents 8c56c6f + 47d33b1 commit b7f5fe5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b7f5fe5

Please sign in to comment.