From 4561a06abe571be2f840fc2a71eae95f1bc3f180 Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Thu, 5 Dec 2024 01:17:15 -0800 Subject: [PATCH] remove lazy_static --- Cargo.lock | 1 - ts-rs/Cargo.toml | 1 - ts-rs/src/export.rs | 10 ++++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44b0aa8b..68a217fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1444,7 +1444,6 @@ dependencies = [ "dprint-plugin-typescript", "heapless", "indexmap", - "lazy_static", "ordered-float", "semver", "serde", diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml index 85d00d48..f380c2dd 100644 --- a/ts-rs/Cargo.toml +++ b/ts-rs/Cargo.toml @@ -60,5 +60,4 @@ smol_str = { version = "0.3", optional = true } indexmap = { version = "2", optional = true } ordered-float = { version = ">= 3, < 5", optional = true } serde_json = { version = "1", optional = true } -lazy_static = { version = "1", default-features = false } tokio = { version = "1", features = ["sync"], optional = true } diff --git a/ts-rs/src/export.rs b/ts-rs/src/export.rs index 3640c96e..7269467a 100644 --- a/ts-rs/src/export.rs +++ b/ts-rs/src/export.rs @@ -6,11 +6,10 @@ use std::{ fs::File, io::{Seek, SeekFrom}, path::{Component, Path, PathBuf}, - sync::Mutex, + sync::{Mutex, LazyLock}, }; pub use error::ExportError; -use lazy_static::lazy_static; use path::diff_paths; pub(crate) use recursive_export::export_all_into; @@ -19,9 +18,8 @@ use crate::TS; mod error; mod path; -lazy_static! { - static ref EXPORT_PATHS: Mutex>> = Mutex::new(HashMap::new()); -} +static EXPORT_PATHS: LazyLock>>> = + LazyLock::new(|| Default::default()); const NOTE: &str = "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n"; @@ -139,7 +137,7 @@ fn export_and_merge( ) -> Result<(), ExportError> { use std::io::{Read, Write}; - let mut lock = EXPORT_PATHS.lock().unwrap(); + let lock = &mut EXPORT_PATHS.lock().unwrap(); let Some(entry) = lock.get_mut(&path) else { // The file hasn't been written to yet, so it must be