diff options
| author | Mo <76752051+mo8it@users.noreply.github.com> | 2024-03-27 14:21:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-27 14:21:11 +0100 |
| commit | deeefcf16c0c48b5c5935987edd04374535d1f02 (patch) | |
| tree | d01c434674058804158f82d393b7e5f0fc98e4f3 /src/main.rs | |
| parent | 87ca05b4bb4436826a61bcbfe946a39a00f00be0 (diff) | |
| parent | 8e0f7e56f7118c90a948634a641b036a28a8d74a (diff) | |
Merge pull request #1913 from mo8it/which
Use `which` instead of running `rustc --version`
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs index 141549c..fe6609d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use std::ffi::OsStr; use std::fs; use std::io::{self, prelude::*}; use std::path::Path; -use std::process::{Command, Stdio}; +use std::process::Command; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{channel, RecvTimeoutError}; use std::sync::{Arc, Mutex}; @@ -100,7 +100,7 @@ fn main() { std::process::exit(1); } - if !rustc_exists() { + if which::which("rustc").is_err() { println!("We cannot find `rustc`."); println!("Try running `rustc --version` to diagnose your problem."); println!("For instructions on how to install Rust, check the README."); @@ -399,18 +399,6 @@ fn watch( } } -fn rustc_exists() -> bool { - Command::new("rustc") - .args(["--version"]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .stdin(Stdio::null()) - .spawn() - .and_then(|mut child| child.wait()) - .map(|status| status.success()) - .unwrap_or(false) -} - const DEFAULT_OUT: &str = "Thanks for installing Rustlings! Is this your first time? Don't worry, Rustlings was made for beginners! We are |
