Skip to content

Commit

Permalink
wip: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EqualMa committed Jul 13, 2023
1 parent 73bd526 commit 9df9d5f
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 229 deletions.
15 changes: 13 additions & 2 deletions crates/frender-intrinsic-component-macro/src/data/with_bounds.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use frender_macro_utils::grouped::{Braced, Parenthesized};
use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::{parse::Parse, punctuated::Punctuated};

use crate::kw;
Expand Down Expand Up @@ -99,6 +100,14 @@ pub struct TypedPatType<Type> {
pub ty: Type,
}

impl<Type: ToTokens> ToTokens for TypedPatType<Type> {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.pat.to_tokens(tokens);
self.colon_token.to_tokens(tokens);
self.ty.to_tokens(tokens);
}
}

impl<Type: Parse> Parse for TypedPatType<Type> {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
Ok(Self {
Expand Down Expand Up @@ -228,9 +237,10 @@ type ImplToken = syn::Token![impl];

/// `impl csr { ... }`
#[derive(Clone)]
pub struct FieldDeclarationWithBoundsImpl<ModIdent, Content> {
pub struct FieldDeclarationWithBoundsImpl<ImplIdent, Content> {
pub impl_token: ImplToken,
pub impl_ident: ModIdent,
pub impl_ident: ImplIdent,
pub where_clause: Option<syn::WhereClause>,
pub content: Braced<Content>,
}

Expand All @@ -239,6 +249,7 @@ impl<ModIdent: Parse, Content: Parse> Parse for FieldDeclarationWithBoundsImpl<M
Ok(Self {
impl_token: input.parse()?,
impl_ident: input.parse()?,
where_clause: input.parse()?,
content: input.parse()?,
})
}
Expand Down
Loading

0 comments on commit 9df9d5f

Please sign in to comment.