Skip to content

Commit 28f9295

Browse files
committed
Use std LazyLock instead of the crate lazy_static
1 parent e704d18 commit 28f9295

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ documentation = "https://docs.rs/matplotlib"
1010
license = "MIT"
1111
keywords = ["plot", "graph", "curve", "surface"]
1212
categories = ["science", "visualization", "mathematics", "graphics"]
13+
rust-version = "1.80"
1314

1415
[dependencies]
1516
numpy = "0.23.0"
1617
ndarray = "0.16.1"
1718
curve-sampling = { version = "0.5", optional = true, git = "https://github.com/Chris00/rust-curve-sampling.git" }
18-
lazy_static = "1.4.0"
1919

2020
[dependencies.pyo3]
2121
version = "0.23.3"

src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
//! [Matplotlib]: https://matplotlib.org/
1111
1212
use std::{
13+
borrow::Cow,
1314
fmt::{Display, Formatter},
1415
marker::PhantomData,
15-
path::Path, borrow::Cow,
16+
path::Path,
17+
sync::LazyLock,
1618
};
17-
use lazy_static::lazy_static;
1819
use pyo3::{
1920
prelude::*,
2021
intern,
@@ -122,16 +123,16 @@ macro_rules! pyimport { ($name: path, $m: literal) => {
122123
})
123124
}}
124125

125-
lazy_static! {
126-
/// ⚠ Accessing these may try to lock Python's GIL. Make sure it is
127-
/// executed outside a call to `Python::with_gil`.
128-
static ref FIGURE: Result<Py<PyModule>, ImportError> = {
126+
/// ⚠ Accessing these may try to lock Python's GIL. Make sure it is
127+
/// executed outside a call to `Python::with_gil`.
128+
static FIGURE: LazyLock<Result<Py<PyModule>, ImportError>> =
129+
LazyLock::new(|| {
129130
pyimport!(matplotlib::FIGURE, "matplotlib.figure")
130-
};
131-
static ref PYPLOT: Result<Py<PyModule>, ImportError> = {
131+
});
132+
static PYPLOT: LazyLock<Result<Py<PyModule>, ImportError>> =
133+
LazyLock::new(|| {
132134
pyimport!(matplotlib::PYPLOT, "matplotlib.pyplot")
133-
};
134-
}
135+
});
135136

136137
// RuntimeWarning: More than 20 figures have been opened. Figures
137138
// created through the pyplot interface (`matplotlib.pyplot.figure`)

0 commit comments

Comments
 (0)