Skip to content

Commit a95d7dc

Browse files
committed
Require rustc 1.51+ for IndexMap::from(array) and IndexSet::from(array)
rust-lang/rust#74878 and rust-lang/rust#65798 were both stabilized in 1.51.
1 parent ec3cf8e commit a95d7dc

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ fn main() {
44
Some(_) => autocfg::emit("has_std"),
55
None => autocfg::new().emit_sysroot_crate("std"),
66
}
7+
autocfg::new().emit_rustc_version(1, 51);
78
autocfg::rerun_path("build.rs");
89
}

src/map.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ where
13421342
}
13431343
}
13441344

1345-
#[cfg(has_std)]
1345+
#[cfg(all(has_std, rustc_1_51))]
13461346
impl<K, V, const N: usize> From<[(K, V); N]> for IndexMap<K, V, RandomState>
13471347
where
13481348
K: Hash + Eq,
@@ -1857,6 +1857,7 @@ mod tests {
18571857
}
18581858

18591859
#[test]
1860+
#[cfg(all(has_std, rustc_1_51))]
18601861
fn from_array() {
18611862
let map = IndexMap::from([(1, 2), (3, 4)]);
18621863
let mut expected = IndexMap::new();

src/set.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ where
840840
}
841841
}
842842

843-
#[cfg(has_std)]
843+
#[cfg(all(has_std, rustc_1_51))]
844844
impl<T, const N: usize> From<[T; N]> for IndexSet<T, RandomState>
845845
where
846846
T: Eq + Hash,
@@ -1728,6 +1728,7 @@ mod tests {
17281728
}
17291729

17301730
#[test]
1731+
#[cfg(all(has_std, rustc_1_51))]
17311732
fn from_array() {
17321733
let set1 = IndexSet::from([1, 2, 3, 4]);
17331734
let set2: IndexSet<_> = [1, 2, 3, 4].into();

0 commit comments

Comments
 (0)