From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [PATCH yew-comp 09/15] tree wide: fix clippy lint "manual_strip"
Date: Fri, 6 Mar 2026 12:21:41 +0100 [thread overview]
Message-ID: <20260306112148.208189-10-s.sterz@proxmox.com> (raw)
In-Reply-To: <20260306112148.208189-1-s.sterz@proxmox.com>
see:
https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
.../pve/lxc_property/lxc_network_property.rs | 4 ++--
src/form/pve/mod.rs | 4 ++--
src/form/pve/qemu_cpu_flags_list.rs | 8 ++++----
src/form/pve/qemu_machine_version_selector.rs | 18 ++++++++++--------
4 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/form/pve/lxc_property/lxc_network_property.rs b/src/form/pve/lxc_property/lxc_network_property.rs
index d33267b..f3e582a 100644
--- a/src/form/pve/lxc_property/lxc_network_property.rs
+++ b/src/form/pve/lxc_property/lxc_network_property.rs
@@ -43,8 +43,8 @@ fn get_schema(name: &str) -> &'static Schema {
}
fn net_property_id(name: &str) -> Option<usize> {
- if name.starts_with("net") {
- if let Ok(id) = name[3..].parse::<usize>() {
+ if let Some(name) = name.strip_prefix("net") {
+ if let Ok(id) = name.parse::<usize>() {
return Some(id);
}
}
diff --git a/src/form/pve/mod.rs b/src/form/pve/mod.rs
index 0be5e6f..c92530a 100644
--- a/src/form/pve/mod.rs
+++ b/src/form/pve/mod.rs
@@ -88,8 +88,8 @@ pub enum PveGuestType {
}
fn parse_unused_key(key: &str) -> Option<usize> {
- if key.starts_with("unused") {
- if let Ok(id) = key[6..].parse::<usize>() {
+ if let Some(key) = key.strip_prefix("unused") {
+ if let Ok(id) = key.parse::<usize>() {
return Some(id);
}
}
diff --git a/src/form/pve/qemu_cpu_flags_list.rs b/src/form/pve/qemu_cpu_flags_list.rs
index 048e268..bfcac50 100644
--- a/src/form/pve/qemu_cpu_flags_list.rs
+++ b/src/form/pve/qemu_cpu_flags_list.rs
@@ -55,10 +55,10 @@ fn parse_flags(flags: &str) -> HashMap<String, bool> {
.filter_map(|flag| {
if flag.is_empty() {
None
- } else if flag.starts_with("+") {
- Some((flag[1..].to_string(), true))
- } else if flag.starts_with("-") {
- Some((flag[1..].to_string(), false))
+ } else if let Some(flag) = flag.strip_prefix("+") {
+ Some((flag.to_string(), true))
+ } else if let Some(flag) = flag.strip_prefix("-") {
+ Some((flag.to_string(), false))
} else {
log::error!("unable to parse cpu flag '{flag}' - missing prefix");
None
diff --git a/src/form/pve/qemu_machine_version_selector.rs b/src/form/pve/qemu_machine_version_selector.rs
index 746aba7..d8a3640 100644
--- a/src/form/pve/qemu_machine_version_selector.rs
+++ b/src/form/pve/qemu_machine_version_selector.rs
@@ -173,18 +173,20 @@ fn extract_version_text(id: &str) -> String {
if id == "pc" || id == "q35" {
return tr!("Latest");
}
- if id.starts_with("pc-q35-") {
- return id[7..].to_string();
+
+ if let Some(id) = id.strip_prefix("pc-q35-") {
+ return id.to_string();
}
- if id.starts_with("pc-i440fx-") {
- return id[10..].to_string();
+ if let Some(id) = id.strip_prefix("pc-i440fx-") {
+ return id.to_string();
}
- if id.starts_with("pc-") {
- return id[3..].to_string();
+ if let Some(id) = id.strip_prefix("pc-") {
+ return id.to_string();
}
- if id.starts_with("virt-") {
- return id[5..].to_string();
+ if let Some(id) = id.strip_prefix("virt-") {
+ return id.to_string();
}
+
id.to_string()
}
--
2.47.3
next prev parent reply other threads:[~2026-03-06 11:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 11:21 [PATCH yew-comp 00/15] clippy clean up proxmox-yew-comp Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 01/15] tree wide: fix clippy lint "useless_conversion" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 02/15] tree wide: fix clippy lint "new_without_default" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 03/15] tree wide: fix clippy lint "redundant_static_lifetimes" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 04/15] tree wide: fix clippy lint "unnecessary_lazy_evaluations" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 05/15] tree wide: fix clippy lint "unwrap_or_default" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 06/15] tree wide: fix clippy lint "clone_on_copy" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 07/15] tree wide: fix clippy lint "collapsible_else_if" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 08/15] tree wide: fix various minor clippy lints Shannon Sterz
2026-03-06 11:21 ` Shannon Sterz [this message]
2026-03-06 11:21 ` [PATCH yew-comp 10/15] lxc_property/qemu_property: fix clippy lint "match_like_matches_macro" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 11/15] firewall_property: fix clippy lint "redundant_guards" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 12/15] qemu_property: fix clippy lint "redundant_pattern_matching" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 13/15] qemu_hardware_pane/lxc_resources_panel: allow clippy::enum_variant_names Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 14/15] tree wide: fix clippy lint "large_enum_variant" Shannon Sterz
2026-03-06 11:21 ` [PATCH yew-comp 15/15] tree wide: allow clippy "too_many_arguments" warning selectively Shannon Sterz
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=20260306112148.208189-10-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=yew-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