read explicit lifetime to FromDsl
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-20 22:02:51 +03:00
parent 7c1cddc759
commit 455d6d00d5
14 changed files with 252 additions and 286 deletions

View file

@ -84,7 +84,7 @@ impl ToTokens for CommandDef {
let mut out = TokenStream2::new();
for (arg, ty) in arm.args() {
write_quote_to(&mut out, quote! {
#arg: Dsl::take_or_fail(self, words)?,
#arg: FromDsl::take_from_or_fail(self, words)?,
});
}
out
@ -137,17 +137,22 @@ impl ToTokens for CommandDef {
#[derive(Clone, Debug)] pub enum #command_enum { #(#variants)* }
/// Not generated by [tengri_proc].
#block
/// Generated by [tengri_proc].
/// Generated by [tengri_proc::command].
///
/// Means [#command_enum] is now a [Command] over [#state].
/// Instances of [#command_enum] can be consumed by a
/// mutable pointer to [#state], invoking predefined operations
/// and optionally returning undo history data.
impl ::tengri::input::Command<#state> for #command_enum {
fn execute (self, state: &mut #state) -> Perhaps<Self> {
match self { #(#implementations)* }
}
}
/// Generated by [tengri_proc].
impl ::tengri::dsl::FromDsl<#state> for #command_enum {
fn take_from <'state, 'source: 'state> (
/// Generated by [tengri_proc::command].
impl<'source> ::tengri::dsl::FromDsl<'source, #state> for #command_enum {
fn take_from <'state> (
state: &'state #state,
words: &mut TokenIter<'source>,
words: &mut ::tengri::dsl::TokenIter<'source>
) -> Perhaps<Self> {
let mut words = words.clone();
let token = words.next();