From a46a9893c1f88bf80e5cfe2816f87afc4dc879d2 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 30 Nov 2021 21:11:47 +0100 Subject: [PATCH] Document which_re in readme --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f20f929..5615c36 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,25 @@ A Rust equivalent of Unix command "which". Locate installed executable in cross * Windows * macOS -## Example +## Examples -To find which rustc exectable binary is using. +1) To find which rustc executable binary is using. -``` rust -use which::which; + ``` rust + use which::which; -let result = which::which("rustc").unwrap(); -assert_eq!(result, PathBuf::from("/usr/bin/rustc")); -``` + 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())); + ``` ## Documentation