@@ -135,6 +135,7 @@ pub struct TySpec<S, T: AstMetadata> {
135135#[ derive_where( Debug , Clone , Serialize , Deserialize ; S ) ]
136136pub struct FnDecl < S , T : AstMetadata > {
137137 pub name : Ident < S , T > ,
138+ pub generics : Vec < GenericDecl < S , T > > ,
138139 pub args : Vec < ArgDecl < S , T > > ,
139140 pub return_ty : Option < TySpec < S , T > > ,
140141 pub scope : Scope < S , T > ,
@@ -316,6 +317,12 @@ pub struct ArgDecl<S, T: AstMetadata> {
316317 pub metadata : T :: ArgDecl ,
317318}
318319
320+ #[ derive_where( Debug , Clone , Serialize , Deserialize ; S ) ]
321+ pub struct GenericDecl < S , T : AstMetadata > {
322+ pub name : Ident < S , T > ,
323+ pub metadata : T :: GenericDecl ,
324+ }
325+
319326#[ derive_where( Debug , Clone , Serialize , Deserialize ; S ) ]
320327pub struct CastExpr < S , T : AstMetadata > {
321328 pub value : Expr < S , T > ,
@@ -383,6 +390,7 @@ pub trait AstMetadata {
383390 type Args : Debug + Clone + Serialize + DeserializeOwned ;
384391 type KwArgValue : Debug + Clone + Serialize + DeserializeOwned ;
385392 type ArgDecl : Debug + Clone + Serialize + DeserializeOwned ;
393+ type GenericDecl : Debug + Clone + Serialize + DeserializeOwned ;
386394 type Scope : Debug + Clone + Serialize + DeserializeOwned ;
387395 type Typ : Debug + Clone + Serialize + DeserializeOwned ;
388396 type CastExpr : Debug + Clone + Serialize + DeserializeOwned ;
@@ -507,6 +515,11 @@ pub trait AstTransformer {
507515 name : & Ident < Self :: OutputS , Self :: OutputMetadata > ,
508516 ty : & TySpec < Self :: OutputS , Self :: OutputMetadata > ,
509517 ) -> <Self :: OutputMetadata as AstMetadata >:: ArgDecl ;
518+ fn dispatch_generic_decl (
519+ & mut self ,
520+ input : & GenericDecl < Self :: InputS , Self :: InputMetadata > ,
521+ name : & Ident < Self :: OutputS , Self :: OutputMetadata > ,
522+ ) -> <Self :: OutputMetadata as AstMetadata >:: GenericDecl ;
510523 fn dispatch_scope (
511524 & mut self ,
512525 input : & Scope < Self :: InputS , Self :: InputMetadata > ,
@@ -608,6 +621,11 @@ pub trait AstTransformer {
608621 input : & FnDecl < Self :: InputS , Self :: InputMetadata > ,
609622 ) -> FnDecl < Self :: OutputS , Self :: OutputMetadata > {
610623 let name = self . transform_ident ( & input. name ) ;
624+ let generics = input
625+ . generics
626+ . iter ( )
627+ . map ( |decl| self . transform_generic_decl ( decl) )
628+ . collect_vec ( ) ;
611629 let args = input
612630 . args
613631 . iter ( )
@@ -621,6 +639,7 @@ pub trait AstTransformer {
621639 let metadata = self . dispatch_fn_decl ( input, & name, & args, & return_ty, & scope) ;
622640 FnDecl {
623641 name,
642+ generics,
624643 args,
625644 return_ty,
626645 scope,
@@ -859,6 +878,15 @@ pub trait AstTransformer {
859878 ArgDecl { name, ty, metadata }
860879 }
861880
881+ fn transform_generic_decl (
882+ & mut self ,
883+ input : & GenericDecl < Self :: InputS , Self :: InputMetadata > ,
884+ ) -> GenericDecl < Self :: OutputS , Self :: OutputMetadata > {
885+ let name = self . transform_ident ( & input. name ) ;
886+ let metadata = self . dispatch_generic_decl ( input, & name) ;
887+ GenericDecl { name, metadata }
888+ }
889+
862890 fn transform_scope (
863891 & mut self ,
864892 input : & Scope < Self :: InputS , Self :: InputMetadata > ,
0 commit comments