File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 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 {
305305 }
306306}
307307
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+
308316impl < A : Into < BoltType > + Clone > From < & [ A ] > for BoltType {
309317 fn from ( value : & [ A ] ) -> Self {
310318 BoltType :: List ( BoltList {
@@ -617,4 +625,19 @@ mod tests {
617625 } )
618626 ) ;
619627 }
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+ }
620643}
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ impl IntoIterator for BoltList {
6262 }
6363}
6464
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+
6573impl From < BoltList > for Vec < String > {
6674 fn from ( value : BoltList ) -> Self {
6775 value. value . into_iter ( ) . map ( |x| x. to_string ( ) ) . collect ( )
You can’t perform that action at this time.
0 commit comments