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

@ -1,8 +1,8 @@
use nu_ansi_term::*;
use nu_engine::command_prelude::*;
use nu_protocol::{engine::StateWorkingSet, Signals};
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::sync::LazyLock;
#[derive(Clone)]
pub struct AnsiCommand;
@ -14,7 +14,7 @@ struct AnsiCode {
}
#[rustfmt::skip]
static CODE_LIST: Lazy<Vec<AnsiCode>> = Lazy::new(|| { vec![
static CODE_LIST: LazyLock<Vec<AnsiCode>> = LazyLock::new(|| { vec![
AnsiCode{ short_name: Some("g"), long_name: "green", code: Color::Green.prefix().to_string()},
AnsiCode{ short_name: Some("gb"), long_name: "green_bold", code: Color::Green.bold().prefix().to_string()},
AnsiCode{ short_name: Some("gu"), long_name: "green_underline", code: Color::Green.underline().prefix().to_string()},
@ -494,8 +494,8 @@ static CODE_LIST: Lazy<Vec<AnsiCode>> = Lazy::new(|| { vec![
]
});
static CODE_MAP: Lazy<HashMap<&'static str, &'static str>> =
Lazy::new(|| build_ansi_hashmap(&CODE_LIST));
static CODE_MAP: LazyLock<HashMap<&'static str, &'static str>> =
LazyLock::new(|| build_ansi_hashmap(&CODE_LIST));
impl Command for AnsiCommand {
fn name(&self) -> &str {

View File

@ -1,7 +1,7 @@
use nix::sys::resource::{rlim_t, Resource, RLIM_INFINITY};
use nu_engine::command_prelude::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
/// An object contains resource related parameters
struct ResourceInfo<'a> {
@ -54,7 +54,7 @@ impl<'a> Default for ResourceInfo<'a> {
}
}
static RESOURCE_ARRAY: Lazy<Vec<ResourceInfo>> = Lazy::new(|| {
static RESOURCE_ARRAY: LazyLock<Vec<ResourceInfo>> = LazyLock::new(|| {
let resources = [
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
(