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/README.md b/README.md index 1b931f0f..ca1bcdea 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,6 @@ Feel free to open an issue, discuss using GitHub discussions or open a PR. [See CONTRIBUTING.md](https://github.com/Aleph-Alpha/ts-rs/blob/main/CONTRIBUTING.md) ### MSRV -The Minimum Supported Rust Version for this crate is 1.63.0 +The Minimum Supported Rust Version for this crate is 1.74.1 License: MIT diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml index 85d00d48..7a4c3c1c 100644 --- a/ts-rs/Cargo.toml +++ b/ts-rs/Cargo.toml @@ -15,7 +15,7 @@ categories = [ "web-programming", ] readme = "../README.md" -rust-version = "1.63.0" +rust-version = "1.74.1" [features] chrono-impl = ["chrono"] @@ -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..b628e56e 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, OnceLock}, }; pub use error::ExportError; -use lazy_static::lazy_static; use path::diff_paths; pub(crate) use recursive_export::export_all_into; @@ -19,8 +18,11 @@ use crate::TS; mod error; mod path; -lazy_static! { - static ref EXPORT_PATHS: Mutex>> = Mutex::new(HashMap::new()); +static EXPORT_PATHS: OnceLock>>> = + OnceLock::new(); + +fn get_export_paths<'a>() -> &'a Mutex>> { + EXPORT_PATHS.get_or_init(|| 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 +141,7 @@ fn export_and_merge( ) -> Result<(), ExportError> { use std::io::{Read, Write}; - let mut lock = EXPORT_PATHS.lock().unwrap(); + let lock = &mut get_export_paths().lock().unwrap(); let Some(entry) = lock.get_mut(&path) else { // The file hasn't been written to yet, so it must be diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index b2bbc073..183d62ad 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -122,7 +122,7 @@ //! [See CONTRIBUTING.md](https://github.com/Aleph-Alpha/ts-rs/blob/main/CONTRIBUTING.md) //! //! ## MSRV -//! The Minimum Supported Rust Version for this crate is 1.63.0 +//! The Minimum Supported Rust Version for this crate is 1.74.1 use std::{ any::TypeId,