mirror of
https://github.com/storytold/winprint.rs.git
synced 2026-10-13 23:17:45 +00:00
chore: migrate lazy_static to OnceLock
This commit is contained in:
2 files changed
+7
-6
No files matched your search
@@ -12,7 +12,6 @@ documentation = "https://docs.rs/winprint"
|
||||
repository = "https://github.com/ArcticLampyrid/winprint.rs/"
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.5"
|
||||
scopeguard = "1.2"
|
||||
sha2 = { version = "0.10", optional = true }
|
||||
bs58 = { version = "0.5", optional = true }
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use crate::bindings::pdfium::*;
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::MutexGuard;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
pub struct PdfiumGuard {
|
||||
inited: bool,
|
||||
}
|
||||
lazy_static! {
|
||||
static ref PDFIUM_GUARD: Mutex<PdfiumGuard> = Mutex::new(PdfiumGuard::new());
|
||||
}
|
||||
|
||||
impl PdfiumGuard {
|
||||
fn new() -> PdfiumGuard {
|
||||
PdfiumGuard { inited: false }
|
||||
@@ -31,7 +29,11 @@ impl PdfiumGuard {
|
||||
}
|
||||
}
|
||||
pub fn get() -> MutexGuard<'static, PdfiumGuard> {
|
||||
PDFIUM_GUARD.lock().unwrap()
|
||||
static PDFIUM_GUARD: OnceLock<Mutex<PdfiumGuard>> = OnceLock::new();
|
||||
PDFIUM_GUARD
|
||||
.get_or_init(|| Mutex::new(PdfiumGuard::new()))
|
||||
.lock()
|
||||
.unwrap()
|
||||
}
|
||||
pub fn guard() -> MutexGuard<'static, PdfiumGuard> {
|
||||
let mut x = Self::get();
|
||||
|
||||
Reference in new issue
Block a user