@@ -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 ,
@@ -28,15 +32,24 @@ macro_rules! impl_from_tree {
2832 <<Pk as MiniscriptKey >:: Hash as core:: str :: FromStr >:: Err : $crate:: prelude:: ToString ,
2933 $( $gen : $gen_con, ) *
3034 {
31- $fn
35+
36+ $( #[ $meta] ) *
37+ fn $fn( $( $arg: $type) * ) -> $ret {
38+ $body
39+ }
3240 }
3341 } ;
3442}
3543
3644/// Macro for implementing FromTree trait. This avoids copying all the Pk::Associated type bounds
3745/// throughout the codebase.
3846macro_rules! impl_from_str {
39- ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty $( , $it: item) * ) => {
47+ ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty,
48+ type Err = $err_ty: ty; ,
49+ $( #[ $meta: meta] ) *
50+ fn $fn: ident ( $( $arg: ident : $type: ty) ,* ) -> $ret: ty
51+ $body: block
52+ ) => {
4053 impl <Pk $( , $gen) * > core:: str :: FromStr for $name
4154 where
4255 Pk : MiniscriptKey + core:: str :: FromStr ,
@@ -45,15 +58,24 @@ macro_rules! impl_from_str {
4558 <<Pk as MiniscriptKey >:: Hash as core:: str :: FromStr >:: Err : $crate:: prelude:: ToString ,
4659 $( $gen : $gen_con, ) *
4760 {
48- $( $it) *
61+ type Err = $err_ty;
62+
63+ $( #[ $meta] ) *
64+ fn $fn( $( $arg: $type) * ) -> $ret {
65+ $body
66+ }
4967 }
5068 } ;
5169}
5270
5371/// Macro for implementing FromTree trait. This avoids copying all the Pk::Associated type bounds
5472/// throughout the codebase.
5573macro_rules! impl_block_str {
56- ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty $( , $it: item) * ) => {
74+ ( $( ; $gen: ident; $gen_con: ident, ) * $name: ty,
75+ $( #[ $meta: meta] ) *
76+ $v: vis fn $fn: ident ( $( $arg: ident : $type: ty, ) * ) -> $ret: ty
77+ $body: block
78+ ) => {
5779 impl <Pk $( , $gen) * > $name
5880 where
5981 Pk : MiniscriptKey + std:: str :: FromStr ,
@@ -62,7 +84,10 @@ macro_rules! impl_block_str {
6284 <<Pk as MiniscriptKey >:: Hash as std:: str :: FromStr >:: Err : std:: string:: ToString ,
6385 $( $gen : $gen_con, ) *
6486 {
65- $( $it) *
87+ $( #[ $meta] ) *
88+ $v fn $fn( $( $arg: $type, ) * ) -> $ret {
89+ $body
90+ }
6691 }
6792 } ;
6893}
0 commit comments