Skip to content

Commit f826a2d

Browse files
committed
refactor(self-update): extract get_and_parse_new_rustup_version()
1 parent b19d033 commit f826a2d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/cli/self_update.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,9 @@ pub(crate) fn update(cfg: &Cfg) -> Result<utils::ExitCode> {
11061106

11071107
match prepare_update()? {
11081108
Some(setup_path) => {
1109-
let version = match get_new_rustup_version(&setup_path) {
1110-
Some(new_version) => parse_new_rustup_version(new_version),
1111-
None => {
1112-
err!("failed to get rustup version");
1113-
return Ok(utils::ExitCode(1));
1114-
}
1109+
let Some(version) = get_and_parse_new_rustup_version(&setup_path) else {
1110+
err!("failed to get rustup version");
1111+
return Ok(utils::ExitCode(1));
11151112
};
11161113

11171114
let _ = common::show_channel_update(
@@ -1135,6 +1132,10 @@ pub(crate) fn update(cfg: &Cfg) -> Result<utils::ExitCode> {
11351132
Ok(utils::ExitCode(0))
11361133
}
11371134

1135+
fn get_and_parse_new_rustup_version(path: &Path) -> Option<String> {
1136+
get_new_rustup_version(path).map(parse_new_rustup_version)
1137+
}
1138+
11381139
fn get_new_rustup_version(path: &Path) -> Option<String> {
11391140
match Command::new(path).arg("--version").output() {
11401141
Err(_) => None,

0 commit comments

Comments
 (0)