diff options
| author | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
| commit | a7c79cb5a04562be10347856642a80f0c4be89fc (patch) | |
| tree | 98fac95855d84f5037a1c6f44061cbe94b550600 /.config/awesome/quarrel/native/src/lenses/calculator.rs | |
| parent | 225eeafcea67d63a608f9c666faf2a2ef014be4a (diff) | |
Diffstat (limited to '.config/awesome/quarrel/native/src/lenses/calculator.rs')
| -rw-r--r-- | .config/awesome/quarrel/native/src/lenses/calculator.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/.config/awesome/quarrel/native/src/lenses/calculator.rs b/.config/awesome/quarrel/native/src/lenses/calculator.rs index 36f9805..a483d10 100644 --- a/.config/awesome/quarrel/native/src/lenses/calculator.rs +++ b/.config/awesome/quarrel/native/src/lenses/calculator.rs @@ -1,22 +1,25 @@ use std::sync::{ + Arc, + LazyLock, + Mutex, atomic::{ AtomicBool, Ordering, }, - Arc, - LazyLock, - Mutex, }; use fend_core::{ - evaluate_with_interrupt, Context, Interrupt, + evaluate_with_interrupt, }; use mlua::prelude::*; use crate::lenses::{ - Cache, Entries, Entry, Lense + Cache, + Entries, + Entry, + Lense, }; static CTX: LazyLock<Mutex<Context>> = LazyLock::new(|| { @@ -32,6 +35,7 @@ pub struct Calculator { impl Lense for Calculator { const NAME: &str = "Calculator"; + const PREFIX: Option<&'static str> = Some("#"); fn init() -> std::sync::Arc<Self> { Arc::new(Calculator::default()) @@ -55,18 +59,14 @@ impl Lense for Calculator { self.should_interrupt.load(Ordering::Relaxed) } - fn entries(&self, _: &Lua, input: String) -> Result<Entries, anyhow::Error> { + fn entries(&self, _: &Lua, input: &str) -> Result<Entries, anyhow::Error> { let result = match evaluate_with_interrupt( input.trim(), &mut CTX.lock().expect("Failed to acquire Fend context lock"), self, ) { - Ok(result) => { - result.get_main_result().to_string() - } - Err(err) => { - err - } + Ok(result) => result.get_main_result().to_string(), + Err(err) => err, }; Ok(if result.is_empty() { @@ -77,11 +77,10 @@ impl Lense for Calculator { exec: None, }) }) - } #[inline] - fn filter(&self, entries: Entries, _: String) -> Entries { + fn filter(&self, entries: Entries, _: &str) -> Entries { entries } } |
