From 46e8d02cd7c8b540efd00cab8ed58572f9ac0379 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 8 Mar 2022 11:52:42 -0500 Subject: [PATCH] remove panic from SteppedVector --- src/misc.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/misc.rs b/src/misc.rs index 697a0a0..60f59e6 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -47,10 +47,9 @@ impl SteppedVector { // Should work.... let possible_i = ((x + self.min) / self.step) as usize; if self.data[possible_i] == x { - return Some(possible_i); - } else if (x >= self.min) && (self.max >= x) { - panic!("possible_i did not result in a possible value, but x is in range"); - // Panic in case (no clue how this would happen). I may remove this check later. + Some(possible_i) + } else { + None } // Not really needed as the above code should handle everything @@ -62,8 +61,8 @@ impl SteppedVector { return Some(i); } } - */ None + */ } }