From: "Daniel Kral" <d.kral@proxmox.com>
To: "Dominik Rusovac" <d.rusovac@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH proxmox] resource-scheduling: topsis: add context to 'unwraps'
Date: Wed, 25 Feb 2026 16:08:07 +0100 [thread overview]
Message-ID: <DGO4Y6RHPGRU.3NC0XBPGR8Q4W@proxmox.com> (raw)
In-Reply-To: <20260225130639.282334-1-d.rusovac@proxmox.com>
Thanks for the patch!
On Wed Feb 25, 2026 at 2:06 PM CET, Dominik Rusovac wrote:
> 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");
Hm, it might make sense to fall back to sensible defaults here or return
a Result<> (as this is only used internally in score_alternatives(...))
and return either an empty vec there or an error as well.
>
> (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] {
next prev parent reply other threads:[~2026-02-25 15:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 13:06 Dominik Rusovac
2026-02-25 15:08 ` Daniel Kral [this message]
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=DGO4Y6RHPGRU.3NC0XBPGR8Q4W@proxmox.com \
--to=d.kral@proxmox.com \
--cc=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 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.