From 41ef632a15c92e66cfb7be71b9a7597c8aa17015 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 30 Mar 2026 12:30:26 +0200 Subject: [PATCH] all: remove once_cell dependency --- Cargo.lock | 1 - Cargo.toml | 1 - src/bugs.rs | 4 ++-- src/cursor.rs | 4 ++-- src/format.rs | 15 +++++++-------- src/gfx_apis/gl.rs | 14 ++++++++++---- src/gfx_apis/gl/egl.rs | 7 +++---- src/utils/oserror.rs | 4 ++-- src/utils/page_size.rs | 5 +++-- src/vulkan_core.rs | 11 +++++------ 10 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 450ce00d..c201fb7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,7 +766,6 @@ dependencies = [ "log", "num-derive", "num-traits", - "once_cell", "opera", "parking_lot", "pin-project", diff --git a/Cargo.toml b/Cargo.toml index 415c39c6..9265a63b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ num-derive = "0.4.2" libloading = "0.9.0" bstr = { version = "1.9.0", default-features = false, features = ["std"] } isnt = "0.2.0" -once_cell = "1.19.0" rand = "0.10.0" smallvec = { version = "1.11.1", features = ["const_generics", "const_new", "union"] } byteorder = "1.5.0" diff --git a/src/bugs.rs b/src/bugs.rs index 9635250b..b62b4d37 100644 --- a/src/bugs.rs +++ b/src/bugs.rs @@ -1,6 +1,6 @@ -use {ahash::AHashMap, once_cell::sync::Lazy}; +use {ahash::AHashMap, std::sync::LazyLock}; -static BUGS: Lazy> = Lazy::new(|| { +static BUGS: LazyLock> = LazyLock::new(|| { let mut map = AHashMap::new(); map.insert( "chromium", diff --git a/src/cursor.rs b/src/cursor.rs index fbbf138d..82ef8188 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -18,7 +18,6 @@ use { byteorder::{LittleEndian, ReadBytesExt}, isnt::std_1::primitive::IsntSliceExt, num_derive::FromPrimitive, - once_cell::sync::Lazy, std::{ cell::Cell, convert::TryInto, @@ -29,6 +28,7 @@ use { mem::MaybeUninit, rc::Rc, slice, str, + sync::LazyLock, time::Duration, }, thiserror::Error, @@ -46,7 +46,7 @@ const HOME: &str = "HOME"; const HEADER_SIZE: u32 = 16; -pub static DEFAULT_CURSOR_SIZE: Lazy = Lazy::new(|| { +pub static DEFAULT_CURSOR_SIZE: LazyLock = LazyLock::new(|| { if let Ok(size) = env::var(XCURSOR_SIZE) && let Ok(val) = size.parse() { diff --git a/src/format.rs b/src/format.rs index 9b752cf0..f5751a45 100644 --- a/src/format.rs +++ b/src/format.rs @@ -13,10 +13,9 @@ use { ahash::AHashMap, ash::vk, jay_config::video::Format as ConfigFormat, - once_cell::sync::Lazy, std::{ - fmt, - fmt::{Debug, Write}, + fmt::{self, Debug, Write}, + sync::LazyLock, }, }; @@ -66,7 +65,7 @@ impl PartialEq for Format { impl Eq for Format {} -static FORMATS_MAP: Lazy> = Lazy::new(|| { +static FORMATS_MAP: LazyLock> = LazyLock::new(|| { let mut map = AHashMap::new(); for format in FORMATS { assert!(map.insert(format.drm, format).is_none()); @@ -74,7 +73,7 @@ static FORMATS_MAP: Lazy> = Lazy::new(|| { map }); -static PW_FORMATS_MAP: Lazy> = Lazy::new(|| { +static PW_FORMATS_MAP: LazyLock> = LazyLock::new(|| { let mut map = AHashMap::new(); for format in FORMATS { if format.pipewire != SPA_VIDEO_FORMAT_UNKNOWN { @@ -84,9 +83,9 @@ static PW_FORMATS_MAP: Lazy> = Lazy::n map }); -static FORMATS_REFS: Lazy> = Lazy::new(|| FORMATS.iter().collect()); +static FORMATS_REFS: LazyLock> = LazyLock::new(|| FORMATS.iter().collect()); -static FORMATS_NAMES: Lazy> = Lazy::new(|| { +static FORMATS_NAMES: LazyLock> = LazyLock::new(|| { let mut map = AHashMap::new(); for format in FORMATS { assert!(map.insert(format.name, format).is_none()); @@ -94,7 +93,7 @@ static FORMATS_NAMES: Lazy> = Lazy::new( map }); -static FORMATS_CONFIG: Lazy> = Lazy::new(|| { +static FORMATS_CONFIG: LazyLock> = LazyLock::new(|| { let mut map = AHashMap::new(); for format in FORMATS { assert!(map.insert(format.config, format).is_none()); diff --git a/src/gfx_apis/gl.rs b/src/gfx_apis/gl.rs index 1afd8c9d..1e974f6a 100644 --- a/src/gfx_apis/gl.rs +++ b/src/gfx_apis/gl.rs @@ -35,7 +35,7 @@ macro_rules! dynload { )* } - pub static $item: once_cell::sync::Lazy> = once_cell::sync::Lazy::new(|| unsafe { + pub static $item: std::sync::LazyLock> = std::sync::LazyLock::new(|| unsafe { use crate::utils::errorfmt::ErrorFmt; let lib = match libloading::Library::new($name) { Ok(l) => l, @@ -94,8 +94,13 @@ use { }, }, isnt::std_1::vec::IsntVecExt, - once_cell::sync::Lazy, - std::{any::Any, cell::RefCell, error::Error, rc::Rc, sync::Arc}, + std::{ + any::Any, + cell::RefCell, + error::Error, + rc::Rc, + sync::{Arc, LazyLock}, + }, thiserror::Error, }; @@ -109,7 +114,8 @@ pub mod sys { pub use super::{egl::sys::*, gl::sys::*}; } -static INIT: Lazy>> = Lazy::new(|| egl::init().map_err(Arc::new)); +static INIT: LazyLock>> = + LazyLock::new(|| egl::init().map_err(Arc::new)); pub(super) fn create_gfx_context( drm: &Drm, diff --git a/src/gfx_apis/gl/egl.rs b/src/gfx_apis/gl/egl.rs index e9adf21a..6bd2119e 100644 --- a/src/gfx_apis/gl/egl.rs +++ b/src/gfx_apis/gl/egl.rs @@ -12,8 +12,7 @@ use { }, bstr::ByteSlice, log::Level, - once_cell::sync::Lazy, - std::ffi::CStr, + std::{ffi::CStr, sync::LazyLock}, sys::{ EGL_BAD_ACCESS, EGL_BAD_ALLOC, EGL_BAD_ATTRIBUTE, EGL_BAD_CONFIG, EGL_BAD_CONTEXT, EGL_BAD_CURRENT_SURFACE, EGL_BAD_DEVICE_EXT, EGL_BAD_DISPLAY, EGL_BAD_MATCH, @@ -28,9 +27,9 @@ pub mod display; pub mod image; pub mod sys; -pub(crate) static PROCS: Lazy> = Lazy::new(ExtProc::load); +pub(crate) static PROCS: LazyLock> = LazyLock::new(ExtProc::load); -pub(crate) static EXTS: Lazy = Lazy::new(get_client_ext); +pub(crate) static EXTS: LazyLock = LazyLock::new(get_client_ext); pub(in crate::gfx_apis::gl) fn init() -> Result<(), RenderError> { let Some(egl) = EGL.as_ref() else { diff --git a/src/utils/oserror.rs b/src/utils/oserror.rs index 62a3d944..2e71c389 100644 --- a/src/utils/oserror.rs +++ b/src/utils/oserror.rs @@ -1,8 +1,8 @@ use { - once_cell::sync::Lazy, std::{ error::Error, fmt::{Display, Formatter}, + sync::LazyLock, }, uapi::{ Errno, @@ -10,7 +10,7 @@ use { }, }; -static ERRORS: Lazy<&'static [Option<&'static str>]> = Lazy::new(|| { +static ERRORS: LazyLock<&'static [Option<&'static str>]> = LazyLock::new(|| { static MSGS: &[(c::c_int, &str)] = &[ (c::EWOULDBLOCK, "Operation would block"), (c::ENOTSUP, "Not supported"), diff --git a/src/utils/page_size.rs b/src/utils/page_size.rs index acf28436..1adc3e8e 100644 --- a/src/utils/page_size.rs +++ b/src/utils/page_size.rs @@ -1,6 +1,7 @@ -use {once_cell::sync::Lazy, uapi::c}; +use {std::sync::LazyLock, uapi::c}; -static PAGE_SIZE: Lazy = Lazy::new(|| uapi::sysconf(c::_SC_PAGESIZE).unwrap_or(4096) as _); +static PAGE_SIZE: LazyLock = + LazyLock::new(|| uapi::sysconf(c::_SC_PAGESIZE).unwrap_or(4096) as _); pub fn page_size() -> usize { *PAGE_SIZE diff --git a/src/vulkan_core.rs b/src/vulkan_core.rs index 546e820d..108f0b51 100644 --- a/src/vulkan_core.rs +++ b/src/vulkan_core.rs @@ -18,13 +18,12 @@ use { }, isnt::std_1::collections::IsntHashMapExt, log::Level, - once_cell::sync::Lazy, run_on_drop::on_drop, std::{ ffi::{CStr, CString, c_void}, fmt::{Display, Formatter}, slice, - sync::Arc, + sync::{Arc, LazyLock}, }, thiserror::Error, uapi::{Ustr, ustr}, @@ -36,11 +35,11 @@ pub mod gpu_alloc_ash; pub mod sync; pub mod timeline_semaphore; -static VULKAN_ENTRY: Lazy>> = - Lazy::new(|| unsafe { Entry::load() }.map_err(Arc::new)); +static VULKAN_ENTRY: LazyLock>> = + LazyLock::new(|| unsafe { Entry::load() }.map_err(Arc::new)); -static VULKAN_VALIDATION: Lazy = - Lazy::new(|| std::env::var("JAY_VULKAN_VALIDATION").ok().as_deref() == Some("1")); +static VULKAN_VALIDATION: LazyLock = + LazyLock::new(|| std::env::var("JAY_VULKAN_VALIDATION").ok().as_deref() == Some("1")); #[derive(Debug, Error)] pub enum VulkanCoreError {