mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 12:38:43 +00:00
Refactor get_target_from_rustc
impl
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
96336e4dd9
commit
9ee2609b25
1 changed files with 11 additions and 9 deletions
|
@ -101,16 +101,18 @@ pub async fn detect_targets() -> Targets {
|
|||
/// Figure out what the host target is using `rustc`.
|
||||
/// If `rustc` is absent, then it would return `None`.
|
||||
async fn get_target_from_rustc() -> Option<Box<str>> {
|
||||
match Command::new("rustc").arg("-vV").output().await {
|
||||
Ok(Output { status, stdout, .. }) if status.success() => Cursor::new(stdout)
|
||||
let Output { status, stdout, .. } = Command::new("rustc").arg("-vV").output().await.ok()?;
|
||||
if !status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Cursor::new(stdout)
|
||||
.lines()
|
||||
.filter_map(|line| line.ok())
|
||||
.find_map(|line| {
|
||||
line.strip_prefix("host: ")
|
||||
.map(|host| host.to_owned().into_boxed_str())
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
|
Loading…
Add table
Reference in a new issue