diff --git a/Cargo.toml b/Cargo.toml index dccbdb4..7fe5f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ libc = "0.2.121" regex = { version = "1.5.5", optional = true } [target.'cfg(windows)'.dependencies] -lazy_static = "1.4.0" +once_cell = "1" [dev-dependencies] tempfile = "3.3.0" diff --git a/src/finder.rs b/src/finder.rs index f08d698..4c5956d 100644 --- a/src/finder.rs +++ b/src/finder.rs @@ -151,29 +151,31 @@ impl Finder { where P: IntoIterator, { + use once_cell::sync::Lazy; + // Sample %PATHEXT%: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC // PATH_EXTENSIONS is then [".COM", ".EXE", ".BAT", …]. // (In one use of PATH_EXTENSIONS we skip the dot, but in the other we need it; // hence its retention.) - lazy_static! { - static ref PATH_EXTENSIONS: Vec = - env::var("PATHEXT") - .map(|pathext| { - pathext.split(';') - .filter_map(|s| { - if s.as_bytes().first() == Some(&b'.') { - Some(s.to_owned()) - } else { - // Invalid segment; just ignore it. - None - } - }) - .collect() - }) - // PATHEXT not being set or not being a proper Unicode string is exceedingly - // improbable and would probably break Windows badly. Still, don't crash: - .unwrap_or_default(); - } + static PATH_EXTENSIONS: Lazy> = Lazy::new(|| { + env::var("PATHEXT") + .map(|pathext| { + pathext + .split(';') + .filter_map(|s| { + if s.as_bytes().first() == Some(&b'.') { + Some(s.to_owned()) + } else { + // Invalid segment; just ignore it. + None + } + }) + .collect() + }) + // PATHEXT not being set or not being a proper Unicode string is exceedingly + // improbable and would probably break Windows badly. Still, don't crash: + .unwrap_or_default() + }); paths .into_iter() diff --git a/src/lib.rs b/src/lib.rs index 86d1918..b9026ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,10 +14,6 @@ //! //! ``` -#[cfg(windows)] -#[macro_use] -extern crate lazy_static; - mod checker; mod error; mod finder;