@@ -19,74 +19,52 @@ use crate::{Miniscript, MiniscriptKey, ScriptContext, Terminal};
19
19
20
20
impl < ' a , Pk : MiniscriptKey , Ctx : ScriptContext > TreeLike for & ' a Miniscript < Pk , Ctx > {
21
21
fn as_node ( & self ) -> Tree < Self > {
22
+ use Terminal :: * ;
22
23
match self . node {
23
- Terminal :: PkK ( ..)
24
- | Terminal :: PkH ( ..)
25
- | Terminal :: RawPkH ( ..)
26
- | Terminal :: After ( ..)
27
- | Terminal :: Older ( ..)
28
- | Terminal :: Sha256 ( ..)
29
- | Terminal :: Hash256 ( ..)
30
- | Terminal :: Ripemd160 ( ..)
31
- | Terminal :: Hash160 ( ..)
32
- | Terminal :: True
33
- | Terminal :: False
34
- | Terminal :: Multi ( ..)
35
- | Terminal :: MultiA ( ..) => Tree :: Nullary ,
36
- Terminal :: Alt ( ref sub)
37
- | Terminal :: Swap ( ref sub)
38
- | Terminal :: Check ( ref sub)
39
- | Terminal :: DupIf ( ref sub)
40
- | Terminal :: Verify ( ref sub)
41
- | Terminal :: NonZero ( ref sub)
42
- | Terminal :: ZeroNotEqual ( ref sub) => Tree :: Unary ( sub) ,
43
- Terminal :: AndV ( ref left, ref right)
44
- | Terminal :: AndB ( ref left, ref right)
45
- | Terminal :: OrB ( ref left, ref right)
46
- | Terminal :: OrD ( ref left, ref right)
47
- | Terminal :: OrC ( ref left, ref right)
48
- | Terminal :: OrI ( ref left, ref right) => Tree :: Binary ( left, right) ,
49
- Terminal :: AndOr ( ref a, ref b, ref c) => Tree :: Nary ( Arc :: from ( [ a. as_ref ( ) , b, c] ) ) ,
50
- Terminal :: Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: as_ref) . collect ( ) ) ,
24
+ PkK ( ..) | PkH ( ..) | RawPkH ( ..) | After ( ..) | Older ( ..) | Sha256 ( ..) | Hash256 ( ..)
25
+ | Ripemd160 ( ..) | Hash160 ( ..) | True | False | Multi ( ..) | MultiA ( ..) => Tree :: Nullary ,
26
+ Alt ( ref sub)
27
+ | Swap ( ref sub)
28
+ | Check ( ref sub)
29
+ | DupIf ( ref sub)
30
+ | Verify ( ref sub)
31
+ | NonZero ( ref sub)
32
+ | ZeroNotEqual ( ref sub) => Tree :: Unary ( sub) ,
33
+ AndV ( ref left, ref right)
34
+ | AndB ( ref left, ref right)
35
+ | OrB ( ref left, ref right)
36
+ | OrD ( ref left, ref right)
37
+ | OrC ( ref left, ref right)
38
+ | OrI ( ref left, ref right) => Tree :: Binary ( left, right) ,
39
+ AndOr ( ref a, ref b, ref c) => Tree :: Nary ( Arc :: from ( [ a. as_ref ( ) , b, c] ) ) ,
40
+ Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: as_ref) . collect ( ) ) ,
51
41
}
52
42
}
53
43
}
54
44
55
45
impl < Pk : MiniscriptKey , Ctx : ScriptContext > TreeLike for Arc < Miniscript < Pk , Ctx > > {
56
46
fn as_node ( & self ) -> Tree < Self > {
47
+ use Terminal :: * ;
57
48
match self . node {
58
- Terminal :: PkK ( ..)
59
- | Terminal :: PkH ( ..)
60
- | Terminal :: RawPkH ( ..)
61
- | Terminal :: After ( ..)
62
- | Terminal :: Older ( ..)
63
- | Terminal :: Sha256 ( ..)
64
- | Terminal :: Hash256 ( ..)
65
- | Terminal :: Ripemd160 ( ..)
66
- | Terminal :: Hash160 ( ..)
67
- | Terminal :: True
68
- | Terminal :: False
69
- | Terminal :: Multi ( ..)
70
- | Terminal :: MultiA ( ..) => Tree :: Nullary ,
71
- Terminal :: Alt ( ref sub)
72
- | Terminal :: Swap ( ref sub)
73
- | Terminal :: Check ( ref sub)
74
- | Terminal :: DupIf ( ref sub)
75
- | Terminal :: Verify ( ref sub)
76
- | Terminal :: NonZero ( ref sub)
77
- | Terminal :: ZeroNotEqual ( ref sub) => Tree :: Unary ( Arc :: clone ( sub) ) ,
78
- Terminal :: AndV ( ref left, ref right)
79
- | Terminal :: AndB ( ref left, ref right)
80
- | Terminal :: OrB ( ref left, ref right)
81
- | Terminal :: OrD ( ref left, ref right)
82
- | Terminal :: OrC ( ref left, ref right)
83
- | Terminal :: OrI ( ref left, ref right) => {
84
- Tree :: Binary ( Arc :: clone ( left) , Arc :: clone ( right) )
85
- }
86
- Terminal :: AndOr ( ref a, ref b, ref c) => {
49
+ PkK ( ..) | PkH ( ..) | RawPkH ( ..) | After ( ..) | Older ( ..) | Sha256 ( ..) | Hash256 ( ..)
50
+ | Ripemd160 ( ..) | Hash160 ( ..) | True | False | Multi ( ..) | MultiA ( ..) => Tree :: Nullary ,
51
+ Alt ( ref sub)
52
+ | Swap ( ref sub)
53
+ | Check ( ref sub)
54
+ | DupIf ( ref sub)
55
+ | Verify ( ref sub)
56
+ | NonZero ( ref sub)
57
+ | ZeroNotEqual ( ref sub) => Tree :: Unary ( Arc :: clone ( sub) ) ,
58
+ AndV ( ref left, ref right)
59
+ | AndB ( ref left, ref right)
60
+ | OrB ( ref left, ref right)
61
+ | OrD ( ref left, ref right)
62
+ | OrC ( ref left, ref right)
63
+ | OrI ( ref left, ref right) => Tree :: Binary ( Arc :: clone ( left) , Arc :: clone ( right) ) ,
64
+ AndOr ( ref a, ref b, ref c) => {
87
65
Tree :: Nary ( Arc :: from ( [ Arc :: clone ( a) , Arc :: clone ( b) , Arc :: clone ( c) ] ) )
88
66
}
89
- Terminal :: Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: clone) . collect ( ) ) ,
67
+ Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: clone) . collect ( ) ) ,
90
68
}
91
69
}
92
70
}
0 commit comments