all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox] resource-scheduling: topsis: add context to 'unwraps'
@ 2026-02-25 13:06 Dominik Rusovac
  2026-02-25 15:08 ` Daniel Kral
  0 siblings, 1 reply; 4+ messages in thread
From: Dominik Rusovac @ 2026-02-25 13:06 UTC (permalink / raw)
  To: pve-devel

Adds context as to why particular 'unwraps' panic.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---
 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-26 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-25 13:06 [PATCH proxmox] resource-scheduling: topsis: add context to 'unwraps' Dominik Rusovac
2026-02-25 15:08 ` Daniel Kral
2026-02-26  9:28   ` Dominik Rusovac
2026-02-26 10:18     ` Daniel Kral

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal