replace lazy_static with once_cell (#7502)

replacing the dependence on `lazy_static` with `once_cell`, this will
ensure that variables are initialized when needed instead of startup
time.
This commit is contained in:
Jaffar Ashoor
2022-12-17 21:30:04 +03:00
committed by GitHub
parent 90849a067f
commit c3c41a61b0
11 changed files with 69 additions and 99 deletions

View File

@ -1,11 +1,11 @@
use indexmap::indexmap;
use indexmap::map::IndexMap;
use lazy_static::lazy_static;
use nu_engine::CallExt;
use nu_protocol::{
ast::Call, engine::Command, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData,
PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use once_cell::sync::Lazy;
// Character used to separate directories in a Path Environment variable on windows is ";"
#[cfg(target_family = "windows")]
@ -17,8 +17,8 @@ const ENV_PATH_SEPARATOR_CHAR: char = ':';
#[derive(Clone)]
pub struct Char;
lazy_static! {
static ref CHAR_MAP: IndexMap<&'static str, String> = indexmap! {
static CHAR_MAP: Lazy<IndexMap<&'static str, String>> = Lazy::new(|| {
indexmap! {
// These are some regular characters that either can't be used or
// it's just easier to use them like this.
@ -146,8 +146,8 @@ lazy_static! {
"unit_separator" => '\x1f'.to_string(),
"unit_sep" => '\x1f'.to_string(),
"us" => '\x1f'.to_string(),
};
}
}
});
impl Command for Char {
fn name(&self) -> &str {