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 <isfarulhaque@proton.me>
This commit is contained in:
innocentzero
2024-04-02 04:51:15 +05:30
parent a963d6a2db
commit c03baf221f
+21 -24
View File
@@ -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"),
}
}