summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-03-25 00:30:01 +0100
committermo8it <mo8it@proton.me>2024-03-25 00:30:01 +0100
commit51b4c240ed006a8279bd94e9b7ed5df67086c86e (patch)
treefda19f10fbda41a7ea648c80c82103dfebc82b12 /src
parent9c6f56b836e91da9071830d4dd4a64417fdced9d (diff)
Use `which` instead of running `rustc --version`
Diffstat (limited to 'src')
-rw-r--r--src/main.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs
index a06f0c5..f932631 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.");
@@ -403,18 +403,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 = r#"Thanks for installing Rustlings!
Is this your first time? Don't worry, Rustlings was made for beginners! We are