Skip to content

Commit be1cfa5

Browse files
committed
Move DistributableToolchain::installed_paths() into Cfg
1 parent 336450d commit be1cfa5

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

src/config.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,20 @@ impl<'a> Cfg<'a> {
427427
Ok(())
428428
}
429429

430+
pub(crate) fn installed_paths<'b>(
431+
&self,
432+
desc: &ToolchainDesc,
433+
path: &'b Path,
434+
) -> anyhow::Result<Vec<InstalledPath<'b>>> {
435+
Ok(vec![
436+
InstalledPath::File {
437+
name: "update hash",
438+
path: self.get_hash_file(desc, false)?,
439+
},
440+
InstalledPath::Dir { path },
441+
])
442+
}
443+
430444
pub(crate) fn get_hash_file(
431445
&self,
432446
toolchain: &ToolchainDesc,
@@ -978,6 +992,12 @@ enum ParseMode {
978992
Both,
979993
}
980994

995+
/// Installed paths
996+
pub(crate) enum InstalledPath<'a> {
997+
File { name: &'static str, path: PathBuf },
998+
Dir { path: &'a Path },
999+
}
1000+
9811001
#[cfg(test)]
9821002
mod tests {
9831003
use super::*;

src/toolchain/distributable.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121

2222
use super::{
2323
names::{LocalToolchainName, ToolchainName},
24-
toolchain::{InstalledPath, Toolchain},
24+
toolchain::Toolchain,
2525
};
2626

2727
/// An official toolchain installed on the local disk
@@ -545,20 +545,6 @@ impl<'a> DistributableToolchain<'a> {
545545
None => Ok(None),
546546
}
547547
}
548-
549-
pub(crate) fn installed_paths<'b>(
550-
cfg: &Cfg<'_>,
551-
desc: &ToolchainDesc,
552-
path: &'b Path,
553-
) -> anyhow::Result<Vec<InstalledPath<'b>>> {
554-
Ok(vec![
555-
InstalledPath::File {
556-
name: "update hash",
557-
path: cfg.get_hash_file(desc, false)?,
558-
},
559-
InstalledPath::Dir { path },
560-
])
561-
}
562548
}
563549

564550
impl<'a> TryFrom<&Toolchain<'a>> for DistributableToolchain<'a> {

src/toolchain/toolchain.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use tracing::info;
1616
use wait_timeout::ChildExt;
1717

1818
use crate::{
19-
config::{ActiveReason, Cfg},
19+
config::{ActiveReason, Cfg, InstalledPath},
2020
dist::PartialToolchainDesc,
2121
env_var, install,
2222
notifications::Notification,
@@ -424,9 +424,7 @@ impl<'a> Toolchain<'a> {
424424
(cfg.notify_handler)(Notification::UninstallingToolchain(&name));
425425
let installed_paths = match &name {
426426
ToolchainName::Custom(_) => Ok(vec![InstalledPath::Dir { path: &path }]),
427-
ToolchainName::Official(desc) => {
428-
DistributableToolchain::installed_paths(cfg, desc, &path)
429-
}
427+
ToolchainName::Official(desc) => cfg.installed_paths(desc, &path),
430428
}?;
431429
for path in installed_paths {
432430
match path {
@@ -459,9 +457,3 @@ impl<'a> Toolchain<'a> {
459457
Ok(())
460458
}
461459
}
462-
463-
/// Installed paths
464-
pub(crate) enum InstalledPath<'a> {
465-
File { name: &'static str, path: PathBuf },
466-
Dir { path: &'a Path },
467-
}

0 commit comments

Comments
 (0)