Skip to content

Commit b7f5fe5

Browse files
author
bors-servo
authored
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 -->
2 parents 8c56c6f + 47d33b1 commit b7f5fe5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ readme = "README.md"
1010
documentation = "http://doc.servo.org/smallvec/"
1111

1212
[features]
13-
heapsizeof = ["heapsize"]
13+
heapsizeof = ["heapsize", "std"]
14+
collections = []
15+
std = []
16+
default = ["std"]
1417

1518
[lib]
1619
name = "smallvec"

lib.rs

+15
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@
66
//! to the heap for larger allocations. This can be a useful optimization for improving cache
77
//! locality and reducing allocator traffic for workloads that fit within the inline buffer.
88
9+
#![cfg_attr(not(feature = "std"), no_std)]
10+
#![cfg_attr(not(feature = "std"), feature(collections))]
11+
12+
13+
#[cfg(not(feature = "std"))]
14+
extern crate collections;
15+
16+
#[cfg(not(feature = "std"))]
17+
use collections::Vec;
18+
919
#[cfg(feature="heapsizeof")]
1020
extern crate heapsize;
1121

22+
#[cfg(not(feature = "std"))]
23+
mod std {
24+
pub use core::*;
25+
}
26+
1227
use std::borrow::{Borrow, BorrowMut};
1328
use std::cmp;
1429
use std::fmt;

0 commit comments

Comments
 (0)