Skip to content

Commit 3ea73ce

Browse files
authored
Merge pull request #64 from ehuss/toolchain-is-needed
Add method to Toolchain to help crater know what to uninstall.
2 parents 4f0def5 + 4f98e4c commit 3ea73ce

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
### Added
9+
10+
- New method `Toolchain::is_needed_by_rustwide` for checking if a toolchain
11+
is needed by rustwide itself (for installing tools).
12+
813
## [0.13.1] - 2021-05-21
914

1015
### Changed

src/toolchain.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ impl Toolchain {
178178
}),
179179
};
180180

181+
/// Returns whether or not this toolchain is needed by rustwide itself.
182+
///
183+
/// This toolchain is used for doing things like installing tools.
184+
///
185+
/// ```rust
186+
/// # use rustwide::Toolchain;
187+
/// let tc = Toolchain::dist("stable-x86_64-unknown-linux-gnu");
188+
/// assert!(tc.is_needed_by_rustwide());
189+
/// let tc = Toolchain::dist("nightly-x86_64-unknown-linux-gnu");
190+
/// assert!(!tc.is_needed_by_rustwide());
191+
/// ```
192+
pub fn is_needed_by_rustwide(&self) -> bool {
193+
match &self.inner {
194+
ToolchainInner::Dist(dist) => dist.name.starts_with(MAIN_TOOLCHAIN_NAME),
195+
#[cfg(feature = "unstable-toolchain-ci")]
196+
_ => false,
197+
}
198+
}
199+
181200
/// Create a new dist toolchain.
182201
///
183202
/// Dist toolchains are all the toolchains available through rustup and distributed from

0 commit comments

Comments
 (0)