From c03baf221f53a4a31f5d4fe1afa9cd9073c71f56 Mon Sep 17 00:00:00 2001 From: innocentzero Date: Mon, 25 Mar 2024 04:33:49 +0530 Subject: [PATCH] refact(rustup): change methods to functions Remove the methods that don't require access to the backend into separate functions rather than have them as methods. Signed-off-by: innocentzero --- .../pacdef_core/src/backend/actual/rustup.rs | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/crates/pacdef_core/src/backend/actual/rustup.rs b/crates/pacdef_core/src/backend/actual/rustup.rs index 6272fab..f4230b6 100644 --- a/crates/pacdef_core/src/backend/actual/rustup.rs +++ b/crates/pacdef_core/src/backend/actual/rustup.rs @@ -139,30 +139,6 @@ impl Rustup { } } - fn get_install_switches(&self, repotype: &str) -> Switches { - match repotype { - "toolchain" => &["toolchain", "install"], - "component" => &["component", "add", "--toolchain"], - _ => panic!("No such type managed by rust"), - } - } - - fn get_remove_switches(&self, repotype: &str) -> Switches { - match repotype { - "toolchain" => &["toolchain", "uninstall"], - "component" => &["component", "remove", "--toolchain"], - _ => panic!("No such type managed by rust"), - } - } - - fn get_info_switches(&self, repotype: &str) -> Switches { - match repotype { - "toolchain" => &["toolchain", "list"], - "component" => &["component", "list", "--installed", "--toolchain"], - _ => panic!("No such type managed by rust"), - } - } - fn run_component_command( &self, args: &[&str], @@ -205,3 +181,24 @@ impl Rustup { Ok(val) } } +fn get_install_switches(repotype: &str) -> Switches { + match repotype { + "toolchain" => &["toolchain", "install"], + "component" => &["component", "add", "--toolchain"], + _ => panic!("No such type managed by rust"), + } +} +fn get_remove_switches(repotype: &str) -> Switches { + match repotype { + "toolchain" => &["toolchain", "uninstall"], + "component" => &["component", "remove", "--toolchain"], + _ => panic!("No such type managed by rust"), + } +} +fn get_info_switches(repotype: &str) -> Switches { + match repotype { + "toolchain" => &["toolchain", "list"], + "component" => &["component", "list", "--installed", "--toolchain"], + _ => panic!("No such type managed by rust"), + } +}