mirror of
https://github.com/openharmony/third_party_rust_rust-smallvec.git
synced 2026-07-21 01:55:25 -04:00
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:
+4
-1
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user