From 7c9816a07e23e9c211bc07383a9e9dc6b6a8fe78 Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Mon, 31 Aug 2026 19:03:51 +0300 Subject: [PATCH] move Keywords to dizzle --- dizzle | 2 +- src/lib.rs | 81 ------------------------------------------------------ 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/dizzle b/dizzle index 0cd70c4..b6c1bb5 160000 --- a/dizzle +++ b/dizzle @@ -1 +1 @@ -Subproject commit 0cd70c4d1ac7299cef32ee0d6a02a632e62d6af3 +Subproject commit b6c1bb5f9400c28de1709df78c18e0d4d5618a15 diff --git a/src/lib.rs b/src/lib.rs index af8f565..1bf8ac2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1898,86 +1898,5 @@ pub trait AsMutOpt { fn as_mut_opt (&mut self) -> Option<&mut T>; } } } -#[cfg(feature = "eval")] pub use self::eval::*; -#[cfg(feature = "eval")] mod eval { - use crate::*; - - /// ``` - /// # use ::tengri::{*, dizzle::*, ratatui::prelude::Color}; - /// - /// #[namespace(bool)] - /// #[namespace(u8)] - /// #[namespace(u16)] - /// #[namespace(Option)] - /// #[namespace(Color get_color)] - /// struct App; - /// - /// fn get_color (state: &App, src: impl Language) -> Perhaps { - /// Ok(if let Some(color) = Tui::eval_color_expr(state, &src)? { - /// Some(color) - /// } else if let Some(sym) = src.word()? { - /// Some(match sym { - /// ":color/bg" => Color::Rgb(28, 32, 36), - /// ":color/fg" => Color::Rgb(98, 92, 96), - /// _ => return Err(format!("not a color: {sym}").into()) - /// }) - /// } else { - /// return Err(format!("not a color: {:?}", src.src()?).into()) - /// }) - /// } - /// - /// impl Interpret>> for App { - /// fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Language) - /// -> Usually>> - /// { - /// self.keyword(to, lang) - /// } - /// } - /// - /// impl Keywords> for App { - /// fn keywords () -> impl Iterator Perhaps>> { - /// [ - /// kw_when, kw_either, kw_split, kw_align, - /// kw_exact, kw_min, kw_max, kw_push, - /// kw_tui_text, kw_tui_fg, kw_tui_bg - /// ].into_iter() - /// } - /// } - /// - /// # fn main () -> tengri::Usually<()> { - /// let state = App; - /// let mut out = Tui::new(80, 25); - /// state.interpret_expr(&mut out, &"")?; - /// state.interpret_expr(&mut out, &"text Hello world!")?; - /// state.interpret_expr(&mut out, &"fg (g 0) (text Hello world!)")?; - /// state.interpret_expr(&mut out, &"bg (g 2) (text Hello world!)")?; - /// state.interpret_expr(&mut out, &"(bg (g 3) (fg (g 4) (text Hello world!)))")?; - /// # Ok(()) } - /// ``` - pub trait Keywords : 'static { - fn keywords <'a> () -> impl Iterator PerhapsRef<'a, V>>; - fn keyword <'a> (&self, to: &mut U, expr: &'a (impl Language + ?Sized)) -> PerhapsRef<'a, V> { - if let Some(expr) = expr.src()? { - for keyword in Self::keywords() { - if let Some(result) = keyword(self, to, &expr)? { - return Ok(Some(result)) - } - } - } - Ok(None) - } - } - - #[macro_export] macro_rules! impl_keywords { - ($T:ty, $U:ty, $V:ty [ $($kw:ident),* ]) => { - impl Keywords<$T, $U> for $V { - fn keywords <'a> () -> impl Iterator PerhapsRef<'a, $U>> { - [ $($kw),* ].into_iter() - } - } - } - } -} - #[cfg(feature = "term")] pub use self::term::*; #[cfg(feature = "term")] mod term;