@@ -19,7 +19,11 @@ macro_rules! policy_str {
1919/// Macro for implementing FromTree trait. This avoids copying all the Pk::Associated type bounds
2020/// throughout the codebase.
2121macro_rules! impl_from_tree {
22- ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty, $fn: item) => {
22+ ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty,
23+ $( #[ $meta: meta] ) *
24+ fn $fn: ident ( $( $arg: ident : $type: ty) ,* ) -> $ret: ty
25+ $body: block
26+ ) => {
2327 impl <Pk $( , $gen) * > $crate:: expression:: FromTree for $name
2428 where
2529 Pk : MiniscriptKey + core:: str :: FromStr ,
@@ -30,15 +34,24 @@ macro_rules! impl_from_tree {
3034 <<Pk as MiniscriptKey >:: Sha256Hash as core:: str :: FromStr >:: Err : $crate:: prelude:: ToString ,
3135 $( $gen : $gen_con, ) *
3236 {
33- $fn
37+
38+ $( #[ $meta] ) *
39+ fn $fn( $( $arg: $type) * ) -> $ret {
40+ $body
41+ }
3442 }
3543 } ;
3644}
3745
3846/// Macro for implementing FromTree trait. This avoids copying all the Pk::Associated type bounds
3947/// throughout the codebase.
4048macro_rules! impl_from_str {
41- ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty $( , $it: item) * ) => {
49+ ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty,
50+ type Err = $err_ty: ty; ,
51+ $( #[ $meta: meta] ) *
52+ fn $fn: ident ( $( $arg: ident : $type: ty) ,* ) -> $ret: ty
53+ $body: block
54+ ) => {
4255 impl <Pk $( , $gen) * > core:: str :: FromStr for $name
4356 where
4457 Pk : MiniscriptKey + core:: str :: FromStr ,
@@ -49,15 +62,24 @@ macro_rules! impl_from_str {
4962 <<Pk as MiniscriptKey >:: Sha256Hash as core:: str :: FromStr >:: Err : $crate:: prelude:: ToString ,
5063 $( $gen : $gen_con, ) *
5164 {
52- $( $it) *
65+ type Err = $err_ty;
66+
67+ $( #[ $meta] ) *
68+ fn $fn( $( $arg: $type) * ) -> $ret {
69+ $body
70+ }
5371 }
5472 } ;
5573}
5674
5775/// Macro for implementing FromTree trait. This avoids copying all the Pk::Associated type bounds
5876/// throughout the codebase.
5977macro_rules! impl_block_str {
60- ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty $( , $it: item) * ) => {
78+ ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty,
79+ $( #[ $meta: meta] ) *
80+ $v: vis fn $fn: ident ( $( $arg: ident : $type: ty, ) * ) -> $ret: ty
81+ $body: block
82+ ) => {
6183 impl <Pk $( , $gen) * > $name
6284 where
6385 Pk : MiniscriptKey + core:: str :: FromStr ,
@@ -68,7 +90,10 @@ macro_rules! impl_block_str {
6890 <<Pk as MiniscriptKey >:: Sha256Hash as core:: str :: FromStr >:: Err : $crate:: prelude:: ToString ,
6991 $( $gen : $gen_con, ) *
7092 {
71- $( $it) *
93+ $( #[ $meta] ) *
94+ $v fn $fn( $( $arg: $type, ) * ) -> $ret {
95+ $body
96+ }
7297 }
7398 } ;
7499}
0 commit comments