summaryrefslogtreecommitdiffstats
path: root/src/assets.rs
diff options
context:
space:
mode:
authorMartin Nordholts <enselic@gmail.com>2021-11-22 20:59:28 +0100
committerMartin Nordholts <enselic@gmail.com>2021-11-22 22:03:03 +0100
commitdd0925a9465978bdd4aef0da45a6f323b6d10774 (patch)
tree1a7c9e95fbcb67b4a091c719d5aec571ca4a3763 /src/assets.rs
parentd7671fa8e37ff7c82cd0eff60cc98028e88b68bf (diff)
Replace lazycell with once_cell
We started to use lazycell because syntect already used it. But syntect has changed to use once_cell. So we should also do that to prepare for using the upcoming version of syntect.
Diffstat (limited to 'src/assets.rs')
-rw-r--r--src/assets.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/assets.rs b/src/assets.rs
index 5a285e4c..206664cc 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -2,7 +2,7 @@ use std::ffi::OsStr;
use std::fs;
use std::path::Path;
-use lazycell::LazyCell;
+use once_cell::unsync::OnceCell;
use syntect::highlighting::{Theme, ThemeSet};
use syntect::parsing::{SyntaxReference, SyntaxSet};
@@ -27,7 +27,7 @@ mod serialized_syntax_set;
#[derive(Debug)]
pub struct HighlightingAssets {
- syntax_set_cell: LazyCell<SyntaxSet>,
+ syntax_set_cell: OnceCell<SyntaxSet>,
serialized_syntax_set: SerializedSyntaxSet,
theme_set: ThemeSet,
@@ -49,7 +49,7 @@ pub(crate) const COMPRESS_THEMES: bool = true;
impl HighlightingAssets {
fn new(serialized_syntax_set: SerializedSyntaxSet, theme_set: ThemeSet) -> Self {
HighlightingAssets {
- syntax_set_cell: LazyCell::new(),
+ syntax_set_cell: OnceCell::new(),
serialized_syntax_set,
theme_set,
fallback_theme: None,
@@ -80,7 +80,7 @@ impl HighlightingAssets {
fn get_syntax_set(&self) -> Result<&SyntaxSet> {
self.syntax_set_cell
- .try_borrow_with(|| self.serialized_syntax_set.deserialize())
+ .get_or_try_init(|| self.serialized_syntax_set.deserialize())
}
/// Use [Self::get_syntaxes] instead