Skip to content

Commit

Permalink
Require rustc 1.51+ for IndexMap::from(array) and `IndexSet::from(a…
Browse files Browse the repository at this point in the history
…rray)`

rust-lang/rust#74878 and
rust-lang/rust#65798 were both stabilized in
1.51.
  • Loading branch information
rouge8 committed Oct 24, 2021
1 parent af2932f commit 7bec2c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ fn main() {
Some(_) => autocfg::emit("has_std"),
None => autocfg::new().emit_sysroot_crate("std"),
}
autocfg::new().emit_rustc_version(1, 51);
autocfg::rerun_path("build.rs");
}
3 changes: 2 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ where
}
}

#[cfg(has_std)]
#[cfg(all(has_std, rustc_1_51))]
impl<K, V, const N: usize> From<[(K, V); N]> for IndexMap<K, V, RandomState>
where
K: Hash + Eq,
Expand Down Expand Up @@ -1855,6 +1855,7 @@ mod tests {
}

#[test]
#[cfg(all(has_std, rustc_1_51))]
fn from_array() {
let map = IndexMap::from([(1, 2), (3, 4)]);
let mut expected = IndexMap::new();
Expand Down
3 changes: 2 additions & 1 deletion src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ where
}
}

#[cfg(has_std)]
#[cfg(all(has_std, rustc_1_51))]
impl<T, const N: usize> From<[T; N]> for IndexSet<T, RandomState>
where
T: Eq + Hash,
Expand Down Expand Up @@ -1726,6 +1726,7 @@ mod tests {
}

#[test]
#[cfg(all(has_std, rustc_1_51))]
fn from_array() {
let set1 = IndexSet::from([1, 2, 3, 4]);
let set2: IndexSet<_> = [1, 2, 3, 4].into();
Expand Down

0 comments on commit 7bec2c5

Please # to comment.