Skip to content

Commit

Permalink
Reduce Rust MSRV to 1.56 (Qiskit#8077)
Browse files Browse the repository at this point in the history
Commit 84cfd5c recently used a `&[char; 2]` as the type in the
constructor of the `std::Pattern` trait, which is a feature of Rust
unstable, and only available in newer versions of Rust.  We've not fixed
an absolute minimum supported Rust version, but have generally tried to
keep things building with at least the last six months' releases.
  • Loading branch information
jakelishman authored and ajavadia committed May 31, 2022
1 parent 98c5af1 commit 8b5babe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/results/marginalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ fn marginalize<T: std::ops::AddAssign + Copy>(
indices: Option<Vec<usize>>,
) -> HashMap<String, T> {
let mut out_counts: HashMap<String, T> = HashMap::with_capacity(counts.len());
let clbit_size = counts.keys().next().unwrap().replace(&['_', ' '], "").len();
let clbit_size = counts
.keys()
.next()
.unwrap()
.replace(|c| c == '_' || c == ' ', "")
.len();
let all_indices: Vec<usize> = (0..clbit_size).collect();
counts
.iter()
.map(|(k, v)| (k.replace(&['_', ' '], ""), *v))
.map(|(k, v)| (k.replace(|c| c == '_' || c == ' ', ""), *v))
.for_each(|(k, v)| match &indices {
Some(indices) => {
if all_indices == *indices {
Expand Down

0 comments on commit 8b5babe

Please sign in to comment.