@@ -815,3 +815,45 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
815
815
}
816
816
}
817
817
}
818
+
819
+ impl < ' a , Pk : MiniscriptKey , Ctx : ScriptContext > IntoIterator for & ' a Terminal < Pk , Ctx > {
820
+ type Item = & ' a Pk ;
821
+ type IntoIter = Box < dyn Iterator < Item = & ' a Pk > + ' a > ;
822
+
823
+ fn into_iter ( self ) -> Self :: IntoIter {
824
+ use std:: iter;
825
+
826
+ match self {
827
+ Terminal :: True => Box :: new ( iter:: empty ( ) ) ,
828
+ Terminal :: False => Box :: new ( iter:: empty ( ) ) ,
829
+ Terminal :: PkK ( ref pk) => Box :: new ( iter:: once ( pk) ) ,
830
+ Terminal :: PkH ( _) => Box :: new ( iter:: empty ( ) ) ,
831
+ Terminal :: After ( _) => Box :: new ( iter:: empty ( ) ) ,
832
+ Terminal :: Older ( _) => Box :: new ( iter:: empty ( ) ) ,
833
+ Terminal :: Sha256 ( _) => Box :: new ( iter:: empty ( ) ) ,
834
+ Terminal :: Hash256 ( _) => Box :: new ( iter:: empty ( ) ) ,
835
+ Terminal :: Ripemd160 ( _) => Box :: new ( iter:: empty ( ) ) ,
836
+ Terminal :: Hash160 ( _) => Box :: new ( iter:: empty ( ) ) ,
837
+ Terminal :: Alt ( ref i) => i. into_iter ( ) ,
838
+ Terminal :: Swap ( ref i) => i. into_iter ( ) ,
839
+ Terminal :: Check ( ref i) => i. into_iter ( ) ,
840
+ Terminal :: DupIf ( ref i) => i. into_iter ( ) ,
841
+ Terminal :: Verify ( ref i) => i. into_iter ( ) ,
842
+ Terminal :: NonZero ( ref i) => i. into_iter ( ) ,
843
+ Terminal :: ZeroNotEqual ( ref i) => i. into_iter ( ) ,
844
+ Terminal :: AndV ( ref i1, ref i2)
845
+ | Terminal :: AndB ( ref i1, ref i2)
846
+ | Terminal :: OrB ( ref i1, ref i2)
847
+ | Terminal :: OrD ( ref i1, ref i2)
848
+ | Terminal :: OrC ( ref i1, ref i2)
849
+ | Terminal :: OrI ( ref i1, ref i2) => Box :: new ( i1. into_iter ( ) . chain ( i2. into_iter ( ) ) ) ,
850
+ Terminal :: AndOr ( ref i1, ref i2, ref i3) => {
851
+ Box :: new ( i1. into_iter ( ) . chain ( i2. into_iter ( ) ) . chain ( i3. into_iter ( ) ) )
852
+ }
853
+ Terminal :: Thresh ( _, ref scripts) => {
854
+ Box :: new ( scripts. iter ( ) . map ( |s| s. into_iter ( ) ) . flatten ( ) )
855
+ }
856
+ Terminal :: Multi ( _, ref pks) => Box :: new ( pks. iter ( ) ) ,
857
+ }
858
+ }
859
+ }
0 commit comments