diff --git a/Cargo.toml b/Cargo.toml index 7708f1a..ce41f6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,12 @@ documentation = "https://docs.rs/matplotlib" license = "MIT" keywords = ["plot", "graph", "curve", "surface"] categories = ["science", "visualization", "mathematics", "graphics"] +rust-version = "1.80" [dependencies] numpy = "0.23.0" ndarray = "0.16.1" curve-sampling = { version = "0.5", optional = true, git = "https://github.com/Chris00/rust-curve-sampling.git" } -lazy_static = "1.4.0" [dependencies.pyo3] version = "0.23.3" diff --git a/src/lib.rs b/src/lib.rs index e1b84ec..b12b2c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,11 +10,12 @@ //! [Matplotlib]: https://matplotlib.org/ use std::{ + borrow::Cow, fmt::{Display, Formatter}, marker::PhantomData, - path::Path, borrow::Cow, + path::Path, + sync::LazyLock, }; -use lazy_static::lazy_static; use pyo3::{ prelude::*, intern, @@ -122,16 +123,16 @@ macro_rules! pyimport { ($name: path, $m: literal) => { }) }} -lazy_static! { - /// ⚠ Accessing these may try to lock Python's GIL. Make sure it is - /// executed outside a call to `Python::with_gil`. - static ref FIGURE: Result, ImportError> = { +/// ⚠ Accessing these may try to lock Python's GIL. Make sure it is +/// executed outside a call to `Python::with_gil`. +static FIGURE: LazyLock, ImportError>> = + LazyLock::new(|| { pyimport!(matplotlib::FIGURE, "matplotlib.figure") - }; - static ref PYPLOT: Result, ImportError> = { + }); +static PYPLOT: LazyLock, ImportError>> = + LazyLock::new(|| { pyimport!(matplotlib::PYPLOT, "matplotlib.pyplot") - }; -} + }); // RuntimeWarning: More than 20 figures have been opened. Figures // created through the pyplot interface (`matplotlib.pyplot.figure`)