File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,14 @@ impl<A: Into<BoltType> + Clone> From<Vec<A>> for BoltType {
305
305
}
306
306
}
307
307
308
+ impl < T : Into < BoltType > > FromIterator < T > for BoltType {
309
+ fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> Self {
310
+ BoltType :: List ( BoltList {
311
+ value : iter. into_iter ( ) . map ( Into :: into) . collect ( ) ,
312
+ } )
313
+ }
314
+ }
315
+
308
316
impl < A : Into < BoltType > + Clone > From < & [ A ] > for BoltType {
309
317
fn from ( value : & [ A ] ) -> Self {
310
318
BoltType :: List ( BoltList {
@@ -617,4 +625,19 @@ mod tests {
617
625
} )
618
626
) ;
619
627
}
628
+
629
+ #[ test]
630
+ fn convert_from_iterator ( ) {
631
+ let value: Vec < i64 > = vec ! [ 42 , 1337 ] ;
632
+ let value: BoltType = value. into_iter ( ) . collect ( ) ;
633
+ assert_eq ! (
634
+ value,
635
+ BoltType :: List ( BoltList {
636
+ value: vec![
637
+ BoltType :: Integer ( BoltInteger :: new( 42 ) ) ,
638
+ BoltType :: Integer ( BoltInteger :: new( 1337 ) ) ,
639
+ ] ,
640
+ } )
641
+ ) ;
642
+ }
620
643
}
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ impl IntoIterator for BoltList {
62
62
}
63
63
}
64
64
65
+ impl < T : Into < BoltType > > FromIterator < T > for BoltList {
66
+ fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> Self {
67
+ BoltList {
68
+ value : iter. into_iter ( ) . map ( Into :: into) . collect ( ) ,
69
+ }
70
+ }
71
+ }
72
+
65
73
impl From < BoltList > for Vec < String > {
66
74
fn from ( value : BoltList ) -> Self {
67
75
value. value . into_iter ( ) . map ( |x| x. to_string ( ) ) . collect ( )
You can’t perform that action at this time.
0 commit comments