@@ -990,6 +990,48 @@ impl<
990990 }
991991}
992992
993+ impl <
994+ ' a ,
995+ T : ' a ,
996+ C0 : TreeNodeContainer < ' a , T > ,
997+ C1 : TreeNodeContainer < ' a , T > ,
998+ C2 : TreeNodeContainer < ' a , T > ,
999+ C3 : TreeNodeContainer < ' a , T > ,
1000+ > TreeNodeContainer < ' a , T > for ( C0 , C1 , C2 , C3 )
1001+ {
1002+ fn apply_elements < F : FnMut ( & ' a T ) -> Result < TreeNodeRecursion > > (
1003+ & ' a self ,
1004+ mut f : F ,
1005+ ) -> Result < TreeNodeRecursion > {
1006+ self . 0
1007+ . apply_elements ( & mut f) ?
1008+ . visit_sibling ( || self . 1 . apply_elements ( & mut f) ) ?
1009+ . visit_sibling ( || self . 2 . apply_elements ( & mut f) ) ?
1010+ . visit_sibling ( || self . 3 . apply_elements ( & mut f) )
1011+ }
1012+
1013+ fn map_elements < F : FnMut ( T ) -> Result < Transformed < T > > > (
1014+ self ,
1015+ mut f : F ,
1016+ ) -> Result < Transformed < Self > > {
1017+ self . 0
1018+ . map_elements ( & mut f) ?
1019+ . map_data ( |new_c0| Ok ( ( new_c0, self . 1 , self . 2 , self . 3 ) ) ) ?
1020+ . transform_sibling ( |( new_c0, c1, c2, c3) | {
1021+ c1. map_elements ( & mut f) ?
1022+ . map_data ( |new_c1| Ok ( ( new_c0, new_c1, c2, c3) ) )
1023+ } ) ?
1024+ . transform_sibling ( |( new_c0, new_c1, c2, c3) | {
1025+ c2. map_elements ( & mut f) ?
1026+ . map_data ( |new_c2| Ok ( ( new_c0, new_c1, new_c2, c3) ) )
1027+ } ) ?
1028+ . transform_sibling ( |( new_c0, new_c1, new_c2, c3) | {
1029+ c3. map_elements ( & mut f) ?
1030+ . map_data ( |new_c3| Ok ( ( new_c0, new_c1, new_c2, new_c3) ) )
1031+ } )
1032+ }
1033+ }
1034+
9931035/// [`TreeNodeRefContainer`] contains references to elements that a function can be
9941036/// applied on. The elements of the container are siblings so the continuation rules are
9951037/// similar to [`TreeNodeRecursion::visit_sibling`].
@@ -1065,6 +1107,27 @@ impl<
10651107 }
10661108}
10671109
1110+ impl <
1111+ ' a ,
1112+ T : ' a ,
1113+ C0 : TreeNodeContainer < ' a , T > ,
1114+ C1 : TreeNodeContainer < ' a , T > ,
1115+ C2 : TreeNodeContainer < ' a , T > ,
1116+ C3 : TreeNodeContainer < ' a , T > ,
1117+ > TreeNodeRefContainer < ' a , T > for ( & ' a C0 , & ' a C1 , & ' a C2 , & ' a C3 )
1118+ {
1119+ fn apply_ref_elements < F : FnMut ( & ' a T ) -> Result < TreeNodeRecursion > > (
1120+ & self ,
1121+ mut f : F ,
1122+ ) -> Result < TreeNodeRecursion > {
1123+ self . 0
1124+ . apply_elements ( & mut f) ?
1125+ . visit_sibling ( || self . 1 . apply_elements ( & mut f) ) ?
1126+ . visit_sibling ( || self . 2 . apply_elements ( & mut f) ) ?
1127+ . visit_sibling ( || self . 3 . apply_elements ( & mut f) )
1128+ }
1129+ }
1130+
10681131/// Transformation helper to process a sequence of iterable tree nodes that are siblings.
10691132pub trait TreeNodeIterator : Iterator {
10701133 /// Apples `f` to each item in this iterator
0 commit comments