diff --git a/Cargo.lock b/Cargo.lock index 153ed7f6..9f4b8093 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,7 +101,6 @@ dependencies = [ "git2", "globset", "grep-cli", - "lazy_static", "nix", "once_cell", "path_abs", diff --git a/Cargo.toml b/Cargo.toml index 539117de..293cc502 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,6 @@ minimal-application = [ "atty", "clap", "dirs-next", - "lazy_static", "paging", "regex-onig", "wild", @@ -48,7 +47,6 @@ ansi_colours = "^1.0" bincode = "1.0" console = "0.15.0" flate2 = "1.0" -lazy_static = { version = "1.4", optional = true } once_cell = "1.8" thiserror = "1.0" wild = { version = "2.0", optional = true } diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 8f913a11..1a618bb2 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -1,21 +1,20 @@ use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand}; +use once_cell::sync::Lazy; use std::env; use std::path::Path; -lazy_static::lazy_static! { - static ref VERSION: String = { - #[cfg(feature = "bugreport")] - let git_version = bugreport::git_version!(fallback = ""); - #[cfg(not(feature = "bugreport"))] - let git_version = ""; +static VERSION: Lazy = Lazy::new(|| { + #[cfg(feature = "bugreport")] + let git_version = bugreport::git_version!(fallback = ""); + #[cfg(not(feature = "bugreport"))] + let git_version = ""; - if git_version.is_empty() { - crate_version!().to_string() - } else { - format!("{} ({})", crate_version!(), git_version) - } - }; -} + if git_version.is_empty() { + crate_version!().to_string() + } else { + format!("{} ({})", crate_version!(), git_version) + } +}); pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() { diff --git a/src/bin/bat/directories.rs b/src/bin/bat/directories.rs index 0bc3c658..5980e3b0 100644 --- a/src/bin/bat/directories.rs +++ b/src/bin/bat/directories.rs @@ -1,7 +1,7 @@ use std::env; use std::path::{Path, PathBuf}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; /// Wrapper for 'dirs' that treats MacOS more like Linux, by following the XDG specification. /// The `XDG_CACHE_HOME` environment variable is checked first. `BAT_CONFIG_DIR` @@ -68,7 +68,5 @@ impl BatProjectDirs { } } -lazy_static! { - pub static ref PROJECT_DIRS: BatProjectDirs = - BatProjectDirs::new().expect("Could not get home directory"); -} +pub static PROJECT_DIRS: Lazy = + Lazy::new(|| BatProjectDirs::new().expect("Could not get home directory"));