From 4561a06abe571be2f840fc2a71eae95f1bc3f180 Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Thu, 5 Dec 2024 01:17:15 -0800 Subject: [PATCH 1/5] 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 From 14dfe09d5a6c6f621c38865e93250ab51ef5285b Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Thu, 5 Dec 2024 10:27:18 -0800 Subject: [PATCH 2/5] update MSRV --- README.md | 2 +- ts-rs/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b931f0f..eff2fb5f 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.80.0 License: MIT diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index b2bbc073..348844c5 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.80.0 use std::{ any::TypeId, From 2f697c8f834f34e114dded38dd423f96ef03a2fc Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Thu, 5 Dec 2024 10:55:51 -0800 Subject: [PATCH 3/5] update rust-version --- ts-rs/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml index f380c2dd..1a750d44 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.80.0" [features] chrono-impl = ["chrono"] From 67c33b19e1afefa2793ff4612e06305f734bd2f5 Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Fri, 6 Dec 2024 00:38:49 -0800 Subject: [PATCH 4/5] change LazyLock to OnceLock --- ts-rs/src/export.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ts-rs/src/export.rs b/ts-rs/src/export.rs index 7269467a..b628e56e 100644 --- a/ts-rs/src/export.rs +++ b/ts-rs/src/export.rs @@ -6,7 +6,7 @@ use std::{ fs::File, io::{Seek, SeekFrom}, path::{Component, Path, PathBuf}, - sync::{Mutex, LazyLock}, + sync::{Mutex, OnceLock}, }; pub use error::ExportError; @@ -18,8 +18,12 @@ use crate::TS; mod error; mod path; -static EXPORT_PATHS: LazyLock>>> = - LazyLock::new(|| Default::default()); +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"; @@ -137,7 +141,7 @@ fn export_and_merge( ) -> Result<(), ExportError> { use std::io::{Read, Write}; - let lock = &mut 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 From 26fa98a5805389fb56ecb19ef115066200260510 Mon Sep 17 00:00:00 2001 From: wladyslaw Date: Fri, 6 Dec 2024 01:17:38 -0800 Subject: [PATCH 5/5] update msrv --- README.md | 2 +- ts-rs/Cargo.toml | 2 +- ts-rs/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eff2fb5f..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.80.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 1a750d44..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.80.0" +rust-version = "1.74.1" [features] chrono-impl = ["chrono"] diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index 348844c5..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.80.0 +//! The Minimum Supported Rust Version for this crate is 1.74.1 use std::{ any::TypeId,