Drop once_cell dependency (#14198)

This PR drops the `once_cell` dependency from all Nu crates, replacing
uses of the
[`Lazy`](https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html)
type with its `std` equivalent,
[`LazyLock`](https://doc.rust-lang.org/std/sync/struct.LazyLock.html).
This commit is contained in:
Alex Ionescu
2024-10-29 17:33:46 +01:00
committed by GitHub
parent 74bd0e32cc
commit e104bccfb9
19 changed files with 44 additions and 53 deletions

View File

@ -2,8 +2,8 @@ use indexmap::{indexmap, IndexMap};
use nu_engine::command_prelude::*;
use nu_protocol::Signals;
use once_cell::sync::Lazy;
use std::collections::HashSet;
use std::sync::LazyLock;
// Character used to separate directories in a Path Environment variable on windows is ";"
#[cfg(target_family = "windows")]
@ -15,7 +15,7 @@ const ENV_PATH_SEPARATOR_CHAR: char = ':';
#[derive(Clone)]
pub struct Char;
static CHAR_MAP: Lazy<IndexMap<&'static str, String>> = Lazy::new(|| {
static CHAR_MAP: LazyLock<IndexMap<&'static str, String>> = LazyLock::new(|| {
indexmap! {
// These are some regular characters that either can't be used or
// it's just easier to use them like this.
@ -150,7 +150,7 @@ static CHAR_MAP: Lazy<IndexMap<&'static str, String>> = Lazy::new(|| {
}
});
static NO_OUTPUT_CHARS: Lazy<HashSet<&'static str>> = Lazy::new(|| {
static NO_OUTPUT_CHARS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
[
// If the character is in the this set, we don't output it to prevent
// the broken of `char --list` command table format and alignment.

View File

@ -1,12 +1,12 @@
use nu_engine::command_prelude::*;
use oem_cp::decode_string_complete_table;
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::sync::LazyLock;
// create a lazycell of all the code_table "Complete" code pages
// the commented out code pages are "Incomplete", which means they
// are stored as Option<char> and not &[char; 128]
static OEM_DECODE: Lazy<HashMap<usize, &[char; 128]>> = Lazy::new(|| {
static OEM_DECODE: LazyLock<HashMap<usize, &[char; 128]>> = LazyLock::new(|| {
let mut m = HashMap::new();
m.insert(437, &oem_cp::code_table::DECODING_TABLE_CP437);
// m.insert(720, &oem_cp::code_table::DECODING_TABLE_CP720);