mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
dsl: Provide -> Take, Receive -> Give (swap + shorten)
This commit is contained in:
parent
583660c330
commit
ddf0c05d5f
10 changed files with 64 additions and 55 deletions
|
|
@ -46,7 +46,7 @@ impl ToTokens for ViewDef {
|
|||
let builtins: Vec<_> = builtins_with_types()
|
||||
.iter()
|
||||
.map(|ty|write_quote(quote! {
|
||||
let value: Option<#ty> = Receive::<#ty>::receive(self, &mut exp.clone())?;
|
||||
let value: Option<#ty> = Give::<#ty>::give(self, &mut exp.clone())?;
|
||||
if let Some(value) = value {
|
||||
return Ok(Some(value.boxed()))
|
||||
}
|
||||
|
|
@ -65,8 +65,8 @@ impl ToTokens for ViewDef {
|
|||
/// Gives [#self_ty] the ability to construct the [Render]able
|
||||
/// which might corresponds to a given [TokenStream],
|
||||
/// while taking [#self_ty]'s state into consideration.
|
||||
impl ::tengri::dsl::Receive<Box<dyn Render<#output>>> for #self_ty {
|
||||
fn receive <'source> (&self, words: &mut ::tengri::dsl::TokenIter<'source>)
|
||||
impl ::tengri::dsl::Give<Box<dyn Render<#output>>> for #self_ty {
|
||||
fn give <'source> (&self, words: &mut ::tengri::dsl::TokenIter<'source>)
|
||||
-> Perhaps<Box<dyn Render<#output>>>
|
||||
{
|
||||
Ok(if let Some(::tengri::dsl::Token { value, .. }) = words.peek() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue