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