|
1 | 1 | use icu_locid::LanguageIdentifier;
|
2 |
| -use intl_memoizer::{concurrent::IntlLangMemoizer, Memoizable}; |
| 2 | +#[cfg(feature = "sync")] |
| 3 | +use intl_memoizer::concurrent::IntlLangMemoizer; |
| 4 | +#[cfg(not(feature = "sync"))] |
| 5 | +use intl_memoizer::IntlLangMemoizer; |
| 6 | +use intl_memoizer::Memoizable; |
3 | 7 | use rustc_hash::FxHashMap;
|
4 | 8 |
|
5 | 9 | use crate::memoizer::MemoizerKind;
|
@@ -51,14 +55,26 @@ impl MemoizerKind for IntlLangMemoizer {
|
51 | 55 | Self::new(lang)
|
52 | 56 | }
|
53 | 57 |
|
| 58 | + #[cfg(feature = "sync")] |
54 | 59 | fn with_try_get_threadsafe<I, R, U>(&self, args: I::Args, cb: U) -> Result<R, I::Error>
|
55 | 60 | where
|
56 | 61 | Self: Sized,
|
57 | 62 | I: Memoizable + Send + Sync + 'static,
|
58 | 63 | I::Args: Send + Sync + 'static,
|
59 | 64 | U: FnOnce(&I) -> R,
|
60 | 65 | {
|
61 |
| - self.with_try_get(args, cb) |
| 66 | + Self::with_try_get(self, args, cb) |
| 67 | + } |
| 68 | + |
| 69 | + #[cfg(not(feature = "sync"))] |
| 70 | + fn with_try_get<I, R, U>(&self, args: I::Args, cb: U) -> Result<R, I::Error> |
| 71 | + where |
| 72 | + Self: Sized, |
| 73 | + I: Memoizable + 'static, |
| 74 | + I::Args: 'static, |
| 75 | + U: FnOnce(&I) -> R, |
| 76 | + { |
| 77 | + Self::with_try_get(self, args, cb) |
62 | 78 | }
|
63 | 79 |
|
64 | 80 | fn stringify_value(&self, value: &dyn FluentType) -> std::borrow::Cow<'static, str> {
|
|
0 commit comments