Skip to content

Commit

Permalink
Fix bug in partial valuation indexing.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Nov 29, 2023
1 parent f862c6b commit 3a60a72
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/_impl_bdd_partial_valuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,18 @@ impl Index<BddVariable> for BddPartialValuation {
type Output = Option<bool>;

fn index(&self, index: BddVariable) -> &Self::Output {
&self.0[usize::from(index.0)]
let index = usize::from(index.0);
if index < self.0.len() {
&self.0[index]
} else {
&None
}
}
}

impl IndexMut<BddVariable> for BddPartialValuation {
fn index_mut(&mut self, index: BddVariable) -> &mut Self::Output {
&mut self.0[usize::from(index.0)]
self.mut_cell(index)
}
}

Expand Down

0 comments on commit 3a60a72

Please sign in to comment.