Skip to content

Commit 61c79ab

Browse files
committed
Swap out lazy_static for std::sync::LazyLock
1 parent 3171178 commit 61c79ab

File tree

7 files changed

+16
-18
lines changed

7 files changed

+16
-18
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Since there is no stable release yet, the changes are organized per day in
1010
reverse chronological order. The main purpose of this document in its current
1111
state is to list breaking changes.
1212

13+
## [2024-08-18]
14+
15+
### Breaking changes
16+
17+
- The minimum supported Rust version has been bumped to 1.80 to replace the last
18+
uses of `lazy_static` with `std::sync::LazyLock`.
19+
1320
## [2024-05-05]
1421

1522
### Breaking changes

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
@@ -2,7 +2,7 @@
22
name = "nih_plug"
33
version = "0.0.0"
44
edition = "2021"
5-
rust-version = "1.70"
5+
rust-version = "1.80"
66
authors = ["Robbert van der Helm <[email protected]>"]
77
license = "ISC"
88

@@ -85,7 +85,6 @@ cfg-if = "1.0"
8585
# This supports CLAP 1.1.8
8686
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", branch = "feature/cstr-macro" }
8787
crossbeam = "0.8"
88-
lazy_static = "1.4"
8988
log = { version = "0.4", features = ["std", "release_max_level_info"] }
9089
midi-consts = "0.1"
9190
nih_log = "0.3.1"

nih_plug_egui/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ raw-window-handle = "0.5"
2121
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "45465c5f46abed6c6ce370fffde5edc8e4cd5aa3" }
2222
crossbeam = "0.8"
2323
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed", default-features = false }
24-
lazy_static = "1.4"
2524
parking_lot = "0.12"
2625
# To make the state persistable
2726
serde = { version = "1.0", features = ["derive"] }

nih_plug_egui/src/widgets/param_slider.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::sync::Arc;
1+
use std::sync::{Arc, LazyLock};
22

33
use egui_baseview::egui::{
44
self, emath, vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget,
55
WidgetText,
66
};
7-
use lazy_static::lazy_static;
87
use nih_plug::prelude::{Param, ParamSetter};
98
use parking_lot::Mutex;
109

@@ -14,11 +13,10 @@ use super::util;
1413
/// noramlized parameter.
1514
const GRANULAR_DRAG_MULTIPLIER: f32 = 0.0015;
1615

17-
lazy_static! {
18-
static ref DRAG_NORMALIZED_START_VALUE_MEMORY_ID: egui::Id = egui::Id::new((file!(), 0));
19-
static ref DRAG_AMOUNT_MEMORY_ID: egui::Id = egui::Id::new((file!(), 1));
20-
static ref VALUE_ENTRY_MEMORY_ID: egui::Id = egui::Id::new((file!(), 2));
21-
}
16+
static DRAG_NORMALIZED_START_VALUE_MEMORY_ID: LazyLock<egui::Id> =
17+
LazyLock::new(|| egui::Id::new((file!(), 0)));
18+
static DRAG_AMOUNT_MEMORY_ID: LazyLock<egui::Id> = LazyLock::new(|| egui::Id::new((file!(), 1)));
19+
static VALUE_ENTRY_MEMORY_ID: LazyLock<egui::Id> = LazyLock::new(|| egui::Id::new((file!(), 2)));
2220

2321
/// A slider widget similar to [`egui::widgets::Slider`] that knows about NIH-plug parameters ranges
2422
/// and can get values for it. The slider supports double click and control click to reset,

src/event_loop/background_thread.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use anymap::Entry;
77
use crossbeam::channel;
88
use parking_lot::Mutex;
9-
use std::sync::{Arc, Weak};
9+
use std::sync::{Arc, LazyLock, Weak};
1010
use std::thread::{self, JoinHandle};
1111

1212
use super::MainThreadExecutor;
@@ -73,10 +73,8 @@ where
7373
// Rust does not allow us to use the `T` and `E` type variable in statics, so this is a
7474
// workaround to have a singleton that also works if for whatever reason there arem ultiple `T`
7575
// and `E`s in a single process (won't happen with normal plugin usage, but sho knwos).
76-
lazy_static::lazy_static! {
77-
static ref HANDLE_MAP: Mutex<anymap::Map<dyn std::any::Any + Send>> =
78-
Mutex::new(anymap::Map::new());
79-
}
76+
static HANDLE_MAP: LazyLock<Mutex<anymap::Map<dyn std::any::Any + Send>>> =
77+
LazyLock::new(|| Mutex::new(anymap::Map::new()));
8078

8179
impl<T: Send + 'static, E: MainThreadExecutor<T> + 'static> WorkerThread<T, E> {
8280
fn spawn() -> Self {

src/wrapper/clap.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub use clap_sys::factory::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FAC
1414
pub use clap_sys::host::clap_host;
1515
pub use clap_sys::plugin::{clap_plugin, clap_plugin_descriptor};
1616
pub use clap_sys::version::CLAP_VERSION;
17-
pub use lazy_static::lazy_static;
1817

1918
/// Export one or more CLAP plugins from this library using the provided plugin types.
2019
#[macro_export]

0 commit comments

Comments
 (0)