mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-28 09:18:53 +01:00
Use once_cell instead of lazy_static
once_cell can do what lazy_static does and more, so replace lazy_static with once_cell. See https://docs.rs/once_cell/1.8.0/once_cell/#general-purpose-lazy-evaluation
This commit is contained in:
parent
dd0925a946
commit
5519f9c716
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -101,7 +101,6 @@ dependencies = [
|
|||||||
"git2",
|
"git2",
|
||||||
"globset",
|
"globset",
|
||||||
"grep-cli",
|
"grep-cli",
|
||||||
"lazy_static",
|
|
||||||
"nix",
|
"nix",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"path_abs",
|
"path_abs",
|
||||||
|
@ -27,7 +27,6 @@ minimal-application = [
|
|||||||
"atty",
|
"atty",
|
||||||
"clap",
|
"clap",
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
"lazy_static",
|
|
||||||
"paging",
|
"paging",
|
||||||
"regex-onig",
|
"regex-onig",
|
||||||
"wild",
|
"wild",
|
||||||
@ -48,7 +47,6 @@ ansi_colours = "^1.0"
|
|||||||
bincode = "1.0"
|
bincode = "1.0"
|
||||||
console = "0.15.0"
|
console = "0.15.0"
|
||||||
flate2 = "1.0"
|
flate2 = "1.0"
|
||||||
lazy_static = { version = "1.4", optional = true }
|
|
||||||
once_cell = "1.8"
|
once_cell = "1.8"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
wild = { version = "2.0", optional = true }
|
wild = { version = "2.0", optional = true }
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand};
|
use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
static VERSION: Lazy<String> = Lazy::new(|| {
|
||||||
static ref VERSION: String = {
|
#[cfg(feature = "bugreport")]
|
||||||
#[cfg(feature = "bugreport")]
|
let git_version = bugreport::git_version!(fallback = "");
|
||||||
let git_version = bugreport::git_version!(fallback = "");
|
#[cfg(not(feature = "bugreport"))]
|
||||||
#[cfg(not(feature = "bugreport"))]
|
let git_version = "";
|
||||||
let git_version = "";
|
|
||||||
|
|
||||||
if git_version.is_empty() {
|
if git_version.is_empty() {
|
||||||
crate_version!().to_string()
|
crate_version!().to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("{} ({})", crate_version!(), git_version)
|
format!("{} ({})", crate_version!(), git_version)
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||||
let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() {
|
let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
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.
|
/// 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`
|
/// The `XDG_CACHE_HOME` environment variable is checked first. `BAT_CONFIG_DIR`
|
||||||
@ -68,7 +68,5 @@ impl BatProjectDirs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
pub static PROJECT_DIRS: Lazy<BatProjectDirs> =
|
||||||
pub static ref PROJECT_DIRS: BatProjectDirs =
|
Lazy::new(|| BatProjectDirs::new().expect("Could not get home directory"));
|
||||||
BatProjectDirs::new().expect("Could not get home directory");
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user