From e68d8a15f43695790d6f8ef29eb2695e80d95cbd Mon Sep 17 00:00:00 2001 From: Math/Nuba <157958916+mquintana1487@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:49:07 +0100 Subject: [PATCH] Close#74issues (#90) --- dessin/Cargo.toml | 1 - dessin/src/shapes/text/font.rs | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dessin/Cargo.toml b/dessin/Cargo.toml index b3c7d67..f9e03ac 100644 --- a/dessin/Cargo.toml +++ b/dessin/Cargo.toml @@ -21,7 +21,6 @@ dessin-macros = { path = "../dessin-macros", version = "0.8.19-pre" } fontdue = "^0.8.0" image = "^0.24.8" nalgebra = "^0.32.3" -once_cell = "^1.19.0" # palette = "^0.7.2" [dev-dependencies] diff --git a/dessin/src/shapes/text/font.rs b/dessin/src/shapes/text/font.rs index 256478b..9c86093 100644 --- a/dessin/src/shapes/text/font.rs +++ b/dessin/src/shapes/text/font.rs @@ -1,22 +1,19 @@ use super::FontWeight; -use once_cell::sync::OnceCell; -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; +use std::sync::OnceLock; +use std::{collections::HashMap, sync::RwLock}; -static FONT_HOLDER: OnceCell>> = OnceCell::new(); +static FONT_HOLDER: OnceLock> = OnceLock::new(); fn font_holder T>(f: F) -> T { f(&FONT_HOLDER - .get_or_init(|| Arc::new(RwLock::new(FontHolder::new()))) + .get_or_init(|| RwLock::new(FontHolder::new())) .read() .unwrap()) } fn font_holder_mut T>(f: F) -> T { f(&mut FONT_HOLDER - .get_or_init(|| Arc::new(RwLock::new(FontHolder::new()))) + .get_or_init(|| RwLock::new(FontHolder::new())) // RwLock is needed to have a mutable case .write() .unwrap()) }