wip: directionalize!

can't fit all into 1 trait because of directionality
of trait implementation rules and constraints :(
This commit is contained in:
🪞👃🪞 2025-05-20 18:48:55 +03:00
parent f797a7143d
commit 7c1cddc759
10 changed files with 221 additions and 222 deletions

View file

@ -60,7 +60,7 @@ impl ToTokens for ExposeDef {
impl ToTokens for ExposeImpl {
fn to_tokens (&self, out: &mut TokenStream2) {
let Self(block, exposed) = self;
let target = &block.self_ty;
let exposed_impl_type = &block.self_ty;
write_quote_to(out, quote! { #block });
for (t, variants) in exposed.iter() {
let formatted_type = format!("{}", quote! { #t });
@ -84,12 +84,13 @@ impl ToTokens for ExposeImpl {
};
let values = variants.iter().map(ExposeArm::from);
write_quote_to(out, quote! {
/// Generated by [tengri_proc].
impl ::tengri::dsl::Dsl<#t> for #target {
fn take <'state, 'source> (
&'state self, iter: &mut ::tengri::dsl::TokenIter<'source>
/// Generated by [tengriproc].
impl ::tengri::dsl::Dsl<#t> for #exposed_impl_type {
fn take <'state, 'source: 'state> (
&'state self,
words: &mut ::tengri::dsl::TokenIter<'source>
) -> Perhaps<#t> {
Ok(Some(match iter.next().map(|x|x.value) {
Ok(Some(match words.next().map(|x|x.value) {
#predefined
#(#values,)*
_ => return Ok(None)