From e986239508a4ddfd122d7fee56f5f6f9301b657c Mon Sep 17 00:00:00 2001 From: mwcz Date: Fri, 28 Jan 2022 14:37:40 -0500 Subject: [PATCH] use once_cell in config crate --- Cargo.lock | 3 +-- Cargo.toml | 1 - components/config/Cargo.toml | 3 +-- components/config/src/highlighting.rs | 17 ++++++----------- components/site/src/lib.rs | 1 - 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6a58522b7..28f83583fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,8 +358,8 @@ name = "config" version = "0.1.0" dependencies = [ "errors", - "lazy_static", "libs", + "once_cell", "serde", "utils", ] @@ -3663,7 +3663,6 @@ dependencies = [ "errors", "front_matter", "hyper", - "lazy_static", "libs", "mime_guess", "notify", diff --git a/Cargo.toml b/Cargo.toml index 7e14095b23..cd6fccd019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ name = "zola" [dependencies] atty = "0.2.11" clap = { version = "3", features = ["derive"] } -lazy_static = "1.1" termcolor = "1.0.4" # Below is for the serve cmd hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] } diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 00f82e94d7..67ef5e8263 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -6,8 +6,7 @@ include = ["src/**/*"] [dependencies] serde = {version = "1.0", features = ["derive"] } -# TODO: remove me if we can get highlight to work with once_cell -lazy_static = "1" +once_cell = "1.9" errors = { path = "../errors" } utils = { path = "../utils" } diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index ece852942d..8ae2c8b805 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -1,23 +1,18 @@ -use lazy_static::lazy_static; use libs::syntect::dumps::from_binary; use libs::syntect::highlighting::{Theme, ThemeSet}; use libs::syntect::html::ClassStyle; use libs::syntect::parsing::{SyntaxReference, SyntaxSet}; +use once_cell::sync::Lazy; use crate::config::Config; pub const CLASS_STYLE: ClassStyle = ClassStyle::SpacedPrefixed { prefix: "z-" }; -// TODO: replace with once_cell. I was getting malloc error with sync::Lazy -lazy_static! { - pub static ref SYNTAX_SET: SyntaxSet = { - let ss: SyntaxSet = - from_binary(include_bytes!("../../../sublime/syntaxes/newlines.packdump")); - ss - }; - pub static ref THEME_SET: ThemeSet = - from_binary(include_bytes!("../../../sublime/themes/all.themedump")); -} +pub static SYNTAX_SET: Lazy = + Lazy::new(|| from_binary(include_bytes!("../../../sublime/syntaxes/newlines.packdump"))); + +pub static THEME_SET: Lazy = + Lazy::new(|| from_binary(include_bytes!("../../../sublime/themes/all.themedump"))); #[derive(Clone, Debug, PartialEq, Eq)] pub enum HighlightSource { diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 548f6a41e7..4edc054697 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -9,7 +9,6 @@ use std::fs::remove_dir_all; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, RwLock}; -// use lazy_static::lazy_static; use libs::once_cell::sync::Lazy; use libs::rayon::prelude::*; use libs::tera::{Context, Tera};