third_party_rust_which-rs/README.md

36 lines
860 B
Markdown
Raw Permalink Normal View History

2021-03-17 17:14:36 +00:00
[![Build Status](https://github.com/harryfei/which-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/harryfei/which-rs/actions/workflows/rust.yml)
2017-09-10 13:57:20 +00:00
2015-10-06 10:35:41 +00:00
# which
2018-12-02 07:59:38 +00:00
A Rust equivalent of Unix command "which". Locate installed executable in cross platforms.
2017-10-04 17:01:32 +00:00
## Support platforms
* Linux
* Windows
* macOS
2015-10-06 10:35:41 +00:00
2021-11-30 20:11:47 +00:00
## Examples
2015-10-06 10:35:41 +00:00
2021-11-30 20:11:47 +00:00
1) To find which rustc executable binary is using.
2015-10-06 10:35:41 +00:00
2021-11-30 20:11:47 +00:00
``` rust
use which::which;
2015-10-06 10:35:41 +00:00
2021-11-30 20:11:47 +00:00
let result = which("rustc").unwrap();
assert_eq!(result, PathBuf::from("/usr/bin/rustc"));
```
2. After enabling the `regex` feature, find all cargo subcommand executables on the path:
``` rust
use which::which_re;
which_re(Regex::new("^cargo-.*").unwrap()).unwrap()
.for_each(|pth| println!("{}", pth.to_string_lossy()));
```
2015-10-06 10:35:41 +00:00
## Documentation
2017-10-04 17:01:32 +00:00
The documentation is [available online](https://docs.rs/which/).