Adds context as to why particular 'unwraps' panic.

Signed-off-by: Dominik Rusovac <[email protected]>
---
 proxmox-resource-scheduling/src/topsis.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/proxmox-resource-scheduling/src/topsis.rs 
b/proxmox-resource-scheduling/src/topsis.rs
index 6d078aa6..25934f5b 100644
--- a/proxmox-resource-scheduling/src/topsis.rs
+++ b/proxmox-resource-scheduling/src/topsis.rs
@@ -145,8 +145,10 @@ impl<const N: usize> IdealAlternatives<N> {
             let min = fixed_criterion
                 .clone()
                 .min_by(|a, b| a.total_cmp(b))
-                .unwrap();
-            let max = fixed_criterion.max_by(|a, b| a.total_cmp(b)).unwrap();
+                .expect("zero alternatives");
+            let max = fixed_criterion
+                .max_by(|a, b| a.total_cmp(b))
+                .expect("zero alternatives");
 
             (best[n], worst[n]) = match criteria[n].maximize {
                 true => (max, min),
@@ -234,8 +236,7 @@ macro_rules! criteria_struct {
                     $(
                         $crate::topsis::Criterion::new($crit_name.to_string(), 
$crit_weight),
                     )*
-                ])
-                .unwrap()
+                ]).unwrap_or_else(|err| panic!("constructing criteria failed: 
{err}"))
             });
 
         impl From<$name> for [f64; $count_name] {
-- 
2.47.3




Reply via email to