From 684c4b09b934ba118fc0256c747ca3ba09a6def4 Mon Sep 17 00:00:00 2001 From: Grant Lemons Date: Thu, 3 Oct 2024 23:37:17 -0600 Subject: [PATCH] change merged_dictionary to use Lrc and make sync conditional for Parser --- harper-core/src/parsers/mod.rs | 7 +++++++ harper-core/src/spell/merged_dictionary.rs | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/harper-core/src/parsers/mod.rs b/harper-core/src/parsers/mod.rs index c1be3796..6f749355 100644 --- a/harper-core/src/parsers/mod.rs +++ b/harper-core/src/parsers/mod.rs @@ -11,6 +11,13 @@ pub use plain_english::PlainEnglish; pub use crate::token::{Token, TokenKind, TokenStringExt}; +#[cfg(not(feature = "concurrent"))] +#[blanket(derive(Box))] +pub trait Parser { + fn parse(&mut self, source: &[char]) -> Vec; +} + +#[cfg(feature = "concurrent")] #[blanket(derive(Box))] pub trait Parser: Send + Sync { fn parse(&mut self, source: &[char]) -> Vec; diff --git a/harper-core/src/spell/merged_dictionary.rs b/harper-core/src/spell/merged_dictionary.rs index bca70e8f..12a137d2 100644 --- a/harper-core/src/spell/merged_dictionary.rs +++ b/harper-core/src/spell/merged_dictionary.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use crate::Lrc; use hashbrown::HashMap; @@ -12,7 +12,7 @@ pub struct MergedDictionary where T: Dictionary + Clone, { - children: Vec>, + children: Vec>, merged: HashMap, } @@ -27,16 +27,16 @@ where } } - pub fn add_dictionary(&mut self, dictionary: Arc) { + pub fn add_dictionary(&mut self, dictionary: Lrc) { self.children.push(dictionary.clone()); } } -impl From> for MergedDictionary +impl From> for MergedDictionary where T: Dictionary + Clone, { - fn from(value: Arc) -> Self { + fn from(value: Lrc) -> Self { Self { children: vec![value], ..Default::default()