From 959218abd6adaa06b80e9adde009ca71ef16694b Mon Sep 17 00:00:00 2001 From: r-vdp Date: Thu, 30 Apr 2026 09:58:22 +0200 Subject: [PATCH] switch-to-configuration-ng: take &Path in is_unit_disabled canonicalize() only needs &self, so there is no reason to take ownership of the PathBuf. Accepting impl AsRef lets the glob iterator call sites keep passing owned PathBufs to .all() while the direct call on new_base_unit_file no longer needs to clone. --- pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs index 4d243693eaa6..e125a67a29f7 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs @@ -1003,8 +1003,9 @@ fn remove_file_if_exists(p: impl AsRef) -> std::io::Result<()> { } /// Checks if a unit has been disabled in configuration -fn is_unit_disabled(unit_file: PathBuf) -> bool { +fn is_unit_disabled(unit_file: impl AsRef) -> bool { unit_file + .as_ref() .canonicalize() .map(|full_path| full_path == Path::new("/dev/null")) .unwrap_or(true) @@ -1105,7 +1106,7 @@ fn collect_unit_changes( { // Account for template unit instances where overrideStrategy == "asDropin" // whilst also allowing manual instances to keep running. - if dropins_removed || is_unit_disabled(new_base_unit_file.clone()) { + if dropins_removed || is_unit_disabled(&new_base_unit_file) { let current_unit_info = parse_unit(¤t_unit_file, ¤t_base_unit_file)?; if parse_systemd_bool(Some(¤t_unit_info), "Unit", "X-StopOnRemoval", true) { _ = units_to_stop.insert(unit.to_string(), ());