remove DslKey
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
🪞👃🪞 2025-08-17 19:32:43 +03:00
parent ddd162f225
commit 1ef898ac32
2 changed files with 1 additions and 24 deletions

View file

@ -242,29 +242,6 @@ dsl_type!(DslText {
}
});
pub const fn is_key_start (c: char) -> bool { matches!(c, '/'|('a'..='z')) }
pub const fn is_key_char (c: char) -> bool { is_key_start(c) || matches!(c, '0'..='9'|'-') }
pub const fn is_key_end (c: char) -> bool { !is_key_char(c) }
dsl_type!(DslKey {
fn key (&self) -> DslPerhaps<&str> { ok_flat(self.src()?.map(key_peek_only)) }
} {
pub const fn key_peek [generated];
pub const fn key_peek_only [generated];
pub const fn key_seek [generated];
pub const fn key_seek_start (src) {
for_each!((i, c) in char_indices(src) =>
if is_key_start(c) { return Ok(Some(i)) } else
if !is_space(c) { return Err(Unexpected(c, Some(i), None)) });
Ok(None)
}
pub const fn key_seek_length (src) {
for_each!((i, c) in char_indices(src) =>
if is_key_end(c) { return Ok(Some(i)) } else
if !is_key_char(c) { return Err(Unexpected(c, Some(i), None)) });
Ok(Some(src.len()))
}
});
dsl_type!(DslNum {
fn num (&self) -> DslPerhaps<&str> {ok_flat(self.src()?.map(num_peek_only))}
} {

View file

@ -87,7 +87,7 @@ impl ExposeImpl {
/// Generated by [tengri_proc::expose].
impl ::tengri::dsl::FromDsl<#state> for #t {
fn from_dsl (state: &#state, dsl: &impl Dsl) -> Perhaps<Self> {
match dsl.key()? {
match dsl.word()? {
Some("true") => Ok(Some(true)),
Some("false") => Ok(Some(false)),
_ => match dsl.word()? { #(#variants)* _ => Ok(None) }