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 Dec 9, 2021
1 parent ec3cf8e commit a95d7dc
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 @@ -1342,7 +1342,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 @@ -1857,6 +1857,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 @@ -840,7 +840,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 @@ -1728,6 +1728,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 a95d7dc

Please sign in to comment.