Skip to content

Commit 3fb870a

Browse files
committed
refactor: remove once_cell
1 parent 828d629 commit 3fb870a

File tree

9 files changed

+18
-29
lines changed

9 files changed

+18
-29
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cargo = {level = "warn", priority = -1}
1616
print_stdout = "warn"
1717
print_stderr = "allow"
1818
dbg_macro = "warn"
19+
non_std_lazy_statics = "warn"
1920

2021
[workspace.dependencies]
2122
base64 = "0.22.0"
@@ -29,7 +30,6 @@ js-sys = "0.3.69"
2930
leptos = "0.6.11"
3031
leptos_router = {version = "0.6.11", features = ["csr"]}
3132
leptos_meta = {version = "0.6.11", features = ["csr"]}
32-
once_cell = "1"
3333
rand = {version = "0.8.5", features = ["small_rng"]}
3434
serde = {version = "1", features = ["derive"]}
3535
serde_json = "1.0.115"
@@ -100,7 +100,6 @@ ecow.workspace = true
100100
enum-iterator.workspace = true
101101
indexmap = {version = "2", features = ["serde"]}
102102
num_cpus = "1.16.0"
103-
once_cell.workspace = true
104103
open = {version = "5", optional = true}
105104
parking_lot = "0.12.1"
106105
paste = "1.0.14"

parser/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ colored.workspace = true
2424
dashmap.workspace = true
2525
ecow.workspace = true
2626
enum-iterator.workspace = true
27-
once_cell.workspace = true
2827
serde = {workspace = true, features = ["rc"]}
2928
unicode-segmentation.workspace = true
3029
serde_tuple = "1.0.0"

parser/src/split.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use std::{collections::HashMap, fmt};
1+
use std::{collections::HashMap, fmt, sync::LazyLock};
22

33
use enum_iterator::Sequence;
4-
use once_cell::sync::Lazy;
54

65
use crate::{ast::NumWord, Complex, SysOp};
76

87
use super::Primitive;
98

10-
static ALIASES: Lazy<HashMap<Primitive, &[&str]>> = Lazy::new(|| {
9+
static ALIASES: LazyLock<HashMap<Primitive, &[&str]>> = LazyLock::new(|| {
1110
[
1211
(Primitive::Identity, &["id"] as &[_]),
1312
(Primitive::Gap, &["ga"]),
@@ -148,7 +147,7 @@ impl Primitive {
148147
if name.len() < 2 {
149148
return None;
150149
}
151-
static REVERSE_ALIASES: Lazy<HashMap<&'static str, Primitive>> = Lazy::new(|| {
150+
static REVERSE_ALIASES: LazyLock<HashMap<&'static str, Primitive>> = LazyLock::new(|| {
152151
ALIASES
153152
.iter()
154153
.flat_map(|(prim, aliases)| aliases.iter().map(|&s| (s, *prim)))

src/constant.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::{
22
f64::consts::TAU,
33
path::{Path, PathBuf},
4-
sync::OnceLock,
4+
sync::{LazyLock, OnceLock},
55
};
66

77
use ecow::EcoVec;
8-
use once_cell::sync::Lazy;
98
use rand::prelude::*;
109

1110
use crate::{
@@ -19,9 +18,9 @@ pub struct ConstantDef {
1918
/// The constant's class
2019
pub class: ConstClass,
2120
/// The constant's value
22-
pub value: Lazy<ConstantValue>,
21+
pub value: LazyLock<ConstantValue>,
2322
/// The constant's documentation
24-
pub doc: Lazy<String>,
23+
pub doc: LazyLock<String>,
2524
/// The suggested replacement because of deprecation
2625
pub deprecation: Option<&'static str>,
2726
}
@@ -135,9 +134,9 @@ macro_rules! constant {
135134
$(#[$attr])*
136135
ConstantDef {
137136
name: $name,
138-
value: Lazy::new(|| {$value.into()}),
137+
value: LazyLock::new(|| {$value.into()}),
139138
class: ConstClass::$class,
140-
doc: Lazy::new(|| {
139+
doc: LazyLock::new(|| {
141140
let mut s = String::new();
142141
$(
143142
s.push_str($doc.trim());

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::{
2020
use clap::{Parser, Subcommand};
2121
use colored::*;
2222
use notify::{event::ModifyKind, EventKind, RecursiveMode, Watcher};
23-
use once_cell::sync::Lazy;
2423
use parking_lot::Mutex;
2524
use rustyline::{error::ReadlineError, DefaultEditor};
2625
use terminal_size::terminal_size;
@@ -34,7 +33,7 @@ use uiua::{
3433
};
3534

3635
static PRESSED_CTRL_C: AtomicBool = AtomicBool::new(false);
37-
static WATCH_CHILD: Lazy<Mutex<Option<Child>>> = Lazy::new(Default::default);
36+
static WATCH_CHILD: Mutex<Option<Child>> = Mutex::new(None);
3837

3938
fn fail<T>(e: UiuaError) -> T {
4039
eprintln!("{}", e.report());

src/stand.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::{env, fs, io, path::Path};
2-
3-
use once_cell::sync::Lazy;
1+
use std::{env, fs, io, path::Path, sync::LazyLock};
42

53
use crate::{Assembly, Compiler, NativeSys, UiuaResult};
64

@@ -43,5 +41,5 @@ fn load_asm() -> io::Result<Option<Assembly>> {
4341
Ok(Some(asm))
4442
}
4543

46-
pub static STAND_ASM: Lazy<Option<Assembly>> =
47-
Lazy::new(|| load_asm().unwrap_or_else(|e| panic!("{e}")));
44+
pub static STAND_ASM: LazyLock<Option<Assembly>> =
45+
LazyLock::new(|| load_asm().unwrap_or_else(|e| panic!("{e}")));

src/sys/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ use std::{
77
mem::take,
88
net::SocketAddr,
99
path::{Path, PathBuf},
10-
sync::Arc,
10+
sync::{Arc, LazyLock},
1111
time::Duration,
1212
};
1313

1414
#[cfg(feature = "image")]
1515
use image::DynamicImage;
16-
use once_cell::sync::Lazy;
1716
use parking_lot::Mutex;
1817
use time::UtcOffset;
1918

@@ -46,13 +45,13 @@ use in example Uiua code ✨";
4645

4746
/// Access the built-in `example.ua` file
4847
pub fn example_ua<T>(f: impl FnOnce(&mut String) -> T) -> T {
49-
static S: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(EXAMPLE_UA.to_string()));
48+
static S: LazyLock<Mutex<String>> = LazyLock::new(|| Mutex::new(EXAMPLE_UA.to_string()));
5049
f(&mut S.lock())
5150
}
5251

5352
/// Access the built-in `example.txt` file
5453
pub fn example_txt<T>(f: impl FnOnce(&mut String) -> T) -> T {
55-
static S: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(EXAMPLE_TXT.to_string()));
54+
static S: LazyLock<Mutex<String>> = LazyLock::new(|| Mutex::new(EXAMPLE_TXT.to_string()));
5655
f(&mut S.lock())
5756
}
5857

src/sys/native.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
slice,
1010
sync::{
1111
atomic::{self, AtomicBool, AtomicU64},
12-
Arc,
12+
Arc, LazyLock,
1313
},
1414
thread::sleep,
1515
time::Duration,
@@ -19,7 +19,6 @@ use colored::Colorize;
1919
#[cfg(feature = "webcam")]
2020
use crossbeam_channel as channel;
2121
use dashmap::DashMap;
22-
use once_cell::sync::Lazy;
2322

2423
use crate::{
2524
terminal_size, GitTarget, Handle, MetaPtr, ReadLinesFn, ReadLinesReturnFn, Span, SysBackend,
@@ -298,7 +297,7 @@ impl GlobalNativeSys {
298297
}
299298
}
300299

301-
static NATIVE_SYS: Lazy<GlobalNativeSys> = Lazy::new(Default::default);
300+
static NATIVE_SYS: LazyLock<GlobalNativeSys> = LazyLock::new(Default::default);
302301

303302
#[cfg(all(feature = "audio", feature = "binary"))]
304303
#[doc(hidden)]

0 commit comments

Comments
 (0)