From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox] resource-scheduling: topsis: add context to 'unwraps'
Date: Wed, 25 Feb 2026 14:06:39 +0100 [thread overview]
Message-ID: <20260225130639.282334-1-d.rusovac@proxmox.com> (raw)
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
next reply other threads:[~2026-02-25 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 13:06 Dominik Rusovac [this message]
2026-02-25 15:08 ` Daniel Kral
2026-02-26 9:28 ` Dominik Rusovac
2026-02-26 10:18 ` Daniel Kral
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225130639.282334-1-d.rusovac@proxmox.com \
--to=d.rusovac@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox