From 3a60a72b97b3520e4f4f1f1631b228598951ac31 Mon Sep 17 00:00:00 2001 From: Samuel Pastva Date: Wed, 29 Nov 2023 10:57:11 +0100 Subject: [PATCH] Fix bug in partial valuation indexing. --- src/_impl_bdd_partial_valuation.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/_impl_bdd_partial_valuation.rs b/src/_impl_bdd_partial_valuation.rs index 34e9e3f..eba3d14 100644 --- a/src/_impl_bdd_partial_valuation.rs +++ b/src/_impl_bdd_partial_valuation.rs @@ -121,13 +121,18 @@ impl Index for BddPartialValuation { type Output = Option; 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 for BddPartialValuation { fn index_mut(&mut self, index: BddVariable) -> &mut Self::Output { - &mut self.0[usize::from(index.0)] + self.mut_cell(index) } }