From a7c79cb5a04562be10347856642a80f0c4be89fc Mon Sep 17 00:00:00 2001 From: delta Date: Fri, 17 Apr 2026 08:10:30 +0200 Subject: sync --- .../quarrel/native/src/lenses/calculator.rs | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to '.config/awesome/quarrel/native/src/lenses/calculator.rs') 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> = 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 { 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 { + fn entries(&self, _: &Lua, input: &str) -> Result { 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 } } -- cgit v1.2.3