Skip to content

Commit c109e5c

Browse files
committed
Do not use the no_std feature
1 parent 4e70e25 commit c109e5c

File tree

4 files changed

+43
-59
lines changed

4 files changed

+43
-59
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ serde = { version = "1", optional = true }
1818
bincode = "1.0.1"
1919

2020
[features]
21-
alloc = []
2221
const_generics = []
23-
default = ["alloc"]
2422
may_dangle = []
2523
specialization = []
26-
std = ["alloc"]
24+
std = []
2725
union = []
2826

2927
[lib]

benches/bench.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#![feature(test)]
22

3-
#[macro_use]
4-
extern crate smallvec;
53
extern crate test;
64

7-
use self::test::Bencher;
8-
use smallvec::{ExtendFromSlice, SmallVec};
5+
use test::Bencher;
6+
use smallvec::{smallvec, ExtendFromSlice, SmallVec};
97

108
const VEC_SIZE: usize = 16;
119
const SPILLED_SIZE: usize = 100;
@@ -273,7 +271,11 @@ fn bench_insert_from_slice(b: &mut Bencher) {
273271
#[bench]
274272
fn bench_macro_from_list(b: &mut Bencher) {
275273
b.iter(|| {
276-
let vec: SmallVec<[u64; 16]> = smallvec![
274+
#[cfg(feature = "const_generics")]
275+
let vec: SmallVec<u64, 16>;
276+
#[cfg(not(feature = "const_generics"))]
277+
let vec: SmallVec<[u64; 16]>;
278+
vec = smallvec![
277279
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 36, 0x40, 0x80,
278280
0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000,
279281
0x80000, 0x100000,
@@ -292,4 +294,4 @@ fn bench_macro_from_list_vec(b: &mut Bencher) {
292294
];
293295
vec
294296
});
295-
}
297+
}

lib.rs

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,8 @@
3131
#![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))]
3232
#![cfg_attr(feature = "specialization", feature(specialization))]
3333
#![cfg_attr(feature = "union", feature(untagged_unions))]
34-
#![cfg_attr(not(feature = "alloc"), no_std)]
3534
#![deny(missing_docs)]
3635

37-
#[cfg(feature = "alloc")]
38-
extern crate alloc;
39-
40-
#[cfg(feature = "serde")]
41-
extern crate serde;
42-
4336
use core::{
4437
borrow::{Borrow, BorrowMut},
4538
cmp,
@@ -1543,23 +1536,15 @@ impl_array!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32
15431536

15441537
#[cfg(test)]
15451538
mod tests {
1546-
use crate::SmallVec;
1539+
extern crate alloc;
15471540

1541+
use crate::SmallVec;
1542+
use alloc::{
1543+
rc::Rc,
1544+
boxed::Box,
1545+
};
15481546
use core::iter::FromIterator;
15491547

1550-
#[cfg(feature = "std")]
1551-
use std::borrow::ToOwned;
1552-
#[cfg(not(feature = "std"))]
1553-
use alloc::borrow::ToOwned;
1554-
#[cfg(feature = "std")]
1555-
use std::rc::Rc;
1556-
#[cfg(not(feature = "std"))]
1557-
use alloc::rc::Rc;
1558-
#[cfg(not(feature = "std"))]
1559-
use alloc::boxed::Box;
1560-
#[cfg(not(feature = "std"))]
1561-
use alloc::vec::Vec;
1562-
15631548
#[test]
15641549
pub fn test_zero() {
15651550
let mut v = SmallVec::<[_; 0]>::new();
@@ -1574,51 +1559,51 @@ mod tests {
15741559
#[test]
15751560
pub fn test_inline() {
15761561
let mut v = SmallVec::<[_; 16]>::new();
1577-
v.push("hello".to_owned());
1578-
v.push("there".to_owned());
1562+
v.push("hello");
1563+
v.push("there");
15791564
assert_eq!(&*v, &[
1580-
"hello".to_owned(),
1581-
"there".to_owned(),
1565+
"hello",
1566+
"there",
15821567
][..]);
15831568
}
15841569

15851570
#[test]
15861571
pub fn test_spill() {
15871572
let mut v = SmallVec::<[_; 2]>::new();
1588-
v.push("hello".to_owned());
1573+
v.push("hello");
15891574
assert_eq!(v[0], "hello");
1590-
v.push("there".to_owned());
1591-
v.push("burma".to_owned());
1575+
v.push("there");
1576+
v.push("burma");
15921577
assert_eq!(v[0], "hello");
1593-
v.push("shave".to_owned());
1578+
v.push("shave");
15941579
assert_eq!(&*v, &[
1595-
"hello".to_owned(),
1596-
"there".to_owned(),
1597-
"burma".to_owned(),
1598-
"shave".to_owned(),
1580+
"hello",
1581+
"there",
1582+
"burma",
1583+
"shave",
15991584
][..]);
16001585
}
16011586

16021587
#[test]
16031588
pub fn test_double_spill() {
16041589
let mut v = SmallVec::<[_; 2]>::new();
1605-
v.push("hello".to_owned());
1606-
v.push("there".to_owned());
1607-
v.push("burma".to_owned());
1608-
v.push("shave".to_owned());
1609-
v.push("hello".to_owned());
1610-
v.push("there".to_owned());
1611-
v.push("burma".to_owned());
1612-
v.push("shave".to_owned());
1590+
v.push("hello");
1591+
v.push("there");
1592+
v.push("burma");
1593+
v.push("shave");
1594+
v.push("hello");
1595+
v.push("there");
1596+
v.push("burma");
1597+
v.push("shave");
16131598
assert_eq!(&*v, &[
1614-
"hello".to_owned(),
1615-
"there".to_owned(),
1616-
"burma".to_owned(),
1617-
"shave".to_owned(),
1618-
"hello".to_owned(),
1619-
"there".to_owned(),
1620-
"burma".to_owned(),
1621-
"shave".to_owned(),
1599+
"hello",
1600+
"there",
1601+
"burma",
1602+
"shave",
1603+
"hello",
1604+
"there",
1605+
"burma",
1606+
"shave",
16221607
][..]);
16231608
}
16241609

scripts/test-common.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
STABLE_FEATURES=(
2-
alloc
32
serde
43
std
54
)

0 commit comments

Comments
 (0)