simplify
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-07-19 08:42:08 +03:00
parent 291b917970
commit 7b67d29c01
19 changed files with 769 additions and 898 deletions

View file

@ -5,6 +5,7 @@
extern crate const_panic;
use const_panic::{concat_panic, PanicFmt};
pub(crate) use ::tengri_core::*;
use std::ops::Deref;
pub(crate) use std::error::Error;
pub(crate) use std::fmt::Debug;
pub(crate) use std::sync::Arc;
@ -61,8 +62,11 @@ pub trait DslExp: PartialEq + Clone + Default + Debug + Dsl {}
impl<T: PartialEq + Clone + Default + Debug + Dsl> DslExp for T {}
/// The string representation for a [Dsl] implementation.
/// [Cst] uses `&'s str`. [Ast] uses `Arc<str>`.
pub trait DslStr: PartialEq + Clone + Default + Debug + AsRef<str> + std::ops::Deref<Target = str> {}
impl<T: PartialEq + Clone + Default + Debug + AsRef<str> + std::ops::Deref<Target = str>> DslStr for T {}
pub trait DslStr: PartialEq + Clone + Default + Debug + AsRef<str> + Deref<Target = str> {
fn as_str (&self) -> &str { self.as_ref() }
fn as_arc (&self) -> Arc<str> { self.as_ref().into() }
}
impl<Str: PartialEq + Clone + Default + Debug + AsRef<str> + Deref<Target = str>> DslStr for Str {}
impl<Str: DslStr, Exp: DslExp + Dsl<Str=Str, Exp=Exp>> Val<Str, Exp> {
pub const fn err (&self) -> Option<DslError> {match self{Val::Error(e)=>Some(*e), _=>None}}
pub const fn nil (&self) -> bool {match self{Val::Nil=>true, _=>false}}