Skip to content

Commit f5f2200

Browse files
committed
Always use an explicit feature for std
1 parent 6705d70 commit f5f2200

File tree

7 files changed

+21
-31
lines changed

7 files changed

+21
-31
lines changed

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ categories = ["data-structures", "no-std"]
1313
[lib]
1414
bench = false
1515

16-
[build-dependencies]
17-
autocfg = "1"
18-
1916
[dependencies]
2017
serde = { version = "1.0", optional = true, default-features = false }
2118
rayon = { version = "1.4.1", optional = true }
@@ -39,7 +36,7 @@ fxhash = "0.2.1"
3936
serde_derive = "1.0"
4037

4138
[features]
42-
# Force the use of `std`, bypassing target detection.
39+
default = ["std"]
4340
std = []
4441

4542
# for testing only, of course

build.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
//! trigger this. It can be tested by building for a std-less target.
6868
//!
6969
//! - Creating maps and sets using [`new`][IndexMap::new] and
70-
//! [`with_capacity`][IndexMap::with_capacity] is unavailable without `std`.
70+
//! [`with_capacity`][IndexMap::with_capacity] is unavailable without `std`.
7171
//! Use methods [`IndexMap::default`][def],
7272
//! [`with_hasher`][IndexMap::with_hasher],
7373
//! [`with_capacity_and_hasher`][IndexMap::with_capacity_and_hasher] instead.
@@ -79,7 +79,7 @@
7979
8080
extern crate alloc;
8181

82-
#[cfg(has_std)]
82+
#[cfg(feature = "std")]
8383
#[macro_use]
8484
extern crate std;
8585

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(has_std)]
1+
#[cfg(feature = "std")]
22
#[macro_export]
33
/// Create an `IndexMap` from a list of key-value pairs
44
///
@@ -35,7 +35,7 @@ macro_rules! indexmap {
3535
};
3636
}
3737

38-
#[cfg(has_std)]
38+
#[cfg(feature = "std")]
3939
#[macro_export]
4040
/// Create an `IndexSet` from a list of values
4141
///

src/map.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ::core::iter::{FromIterator, FusedIterator};
1616
use ::core::ops::{Index, IndexMut, RangeBounds};
1717
use ::core::slice::{Iter as SliceIter, IterMut as SliceIterMut};
1818

19-
#[cfg(has_std)]
19+
#[cfg(feature = "std")]
2020
use std::collections::hash_map::RandomState;
2121

2222
use self::core::IndexMapCore;
@@ -67,12 +67,12 @@ pub use self::core::{Entry, OccupiedEntry, VacantEntry};
6767
/// assert_eq!(letters[&'u'], 1);
6868
/// assert_eq!(letters.get(&'y'), None);
6969
/// ```
70-
#[cfg(has_std)]
70+
#[cfg(feature = "std")]
7171
pub struct IndexMap<K, V, S = RandomState> {
7272
pub(crate) core: IndexMapCore<K, V>,
7373
hash_builder: S,
7474
}
75-
#[cfg(not(has_std))]
75+
#[cfg(not(feature = "std"))]
7676
pub struct IndexMap<K, V, S> {
7777
pub(crate) core: IndexMapCore<K, V>,
7878
hash_builder: S,
@@ -140,7 +140,7 @@ where
140140
}
141141
}
142142

143-
#[cfg(has_std)]
143+
#[cfg(feature = "std")]
144144
impl<K, V> IndexMap<K, V> {
145145
/// Create a new map. (Does not allocate.)
146146
#[inline]
@@ -1391,7 +1391,7 @@ where
13911391
}
13921392
}
13931393

1394-
#[cfg(all(has_std, rustc_1_51))]
1394+
#[cfg(feature = "std")]
13951395
impl<K, V, const N: usize> From<[(K, V); N]> for IndexMap<K, V, RandomState>
13961396
where
13971397
K: Hash + Eq,
@@ -1906,7 +1906,7 @@ mod tests {
19061906
}
19071907

19081908
#[test]
1909-
#[cfg(all(has_std, rustc_1_51))]
1909+
#[cfg(feature = "std")]
19101910
fn from_array() {
19111911
let map = IndexMap::from([(1, 2), (3, 4)]);
19121912
let mut expected = IndexMap::new();

src/set.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[cfg(feature = "rayon")]
44
pub use crate::rayon::set as rayon;
55

6-
#[cfg(has_std)]
6+
#[cfg(feature = "std")]
77
use std::collections::hash_map::RandomState;
88

99
use crate::vec::{self, Vec};
@@ -59,11 +59,11 @@ type Bucket<T> = super::Bucket<T, ()>;
5959
/// assert!(letters.contains(&'u'));
6060
/// assert!(!letters.contains(&'y'));
6161
/// ```
62-
#[cfg(has_std)]
62+
#[cfg(feature = "std")]
6363
pub struct IndexSet<T, S = RandomState> {
6464
pub(crate) map: IndexMap<T, (), S>,
6565
}
66-
#[cfg(not(has_std))]
66+
#[cfg(not(feature = "std"))]
6767
pub struct IndexSet<T, S> {
6868
pub(crate) map: IndexMap<T, (), S>,
6969
}
@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
#[cfg(has_std)]
127+
#[cfg(feature = "std")]
128128
impl<T> IndexSet<T> {
129129
/// Create a new set. (Does not allocate.)
130130
pub fn new() -> Self {
@@ -877,7 +877,7 @@ where
877877
}
878878
}
879879

880-
#[cfg(all(has_std, rustc_1_51))]
880+
#[cfg(feature = "std")]
881881
impl<T, const N: usize> From<[T; N]> for IndexSet<T, RandomState>
882882
where
883883
T: Eq + Hash,
@@ -1765,7 +1765,7 @@ mod tests {
17651765
}
17661766

17671767
#[test]
1768-
#[cfg(all(has_std, rustc_1_51))]
1768+
#[cfg(feature = "std")]
17691769
fn from_array() {
17701770
let set1 = IndexSet::from([1, 2, 3, 4]);
17711771
let set2: IndexSet<_> = [1, 2, 3, 4].into();

test-nostd/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ version = "0.1.0"
44
publish = false
55
edition = "2021"
66

7-
[dependencies]
8-
indexmap = { path = "..", features = ["serde"] }
7+
[dependencies.indexmap]
8+
path = ".."
9+
default-features = false
10+
features = ["serde"]
911

1012
[dev-dependencies]

0 commit comments

Comments
 (0)