@@ -420,7 +420,6 @@ impl<'w, 's, 'a, 'b, T: 'static + Send + Sync> Chain<'w, 's, 'a, 'b, T> {
420
420
/// `unzip_build` allows you to split it into multiple chains (one for each
421
421
/// tuple element) and apply a separate builder function to each chain. You
422
422
/// will be passed back the zipped output of all the builder functions.
423
- #[ must_use]
424
423
pub fn unzip_build < Build > ( self , build : Build ) -> Build :: ReturnType
425
424
where
426
425
Build : UnzipBuilder < T >
@@ -795,41 +794,50 @@ mod tests {
795
794
assert ! ( context. no_unhandled_errors( ) ) ;
796
795
}
797
796
798
- // #[test]
799
- // fn test_unzip() {
800
- // let mut context = TestingContext::minimal_plugins();
797
+ #[ test]
798
+ fn test_unzip ( ) {
799
+ let mut context = TestingContext :: minimal_plugins ( ) ;
801
800
802
- // let mut promise = context.build(|commands| {
803
- // commands
804
- // .request((2.0, 3.0), add.into_blocking_map())
805
- // .map_block(|v| (v, 2.0*v))
806
- // .unzip_build((
807
- // |chain: Chain<f64>| {
808
- // chain
809
- // .map_block(|v| (v, 10.0))
810
- // .map_block(add)
811
- // .dangle()
812
- // },
813
- // |chain: Chain<f64>| {
814
- // chain
815
- // .map_block(|value|
816
- // WaitRequest{
817
- // duration: std::time::Duration::from_secs_f64(0.01),
818
- // value,
819
- // }
820
- // )
821
- // .map_async(wait)
822
- // .dangle()
823
- // }
824
- // ))
825
- // .bundle()
826
- // .race_bundle(commands)
827
- // .take()
828
- // });
801
+ let workflow = context. build_io_workflow ( |scope, builder| {
802
+ scope. input . chain ( builder)
803
+ . map_block ( add)
804
+ . map_block ( |v| ( v, 2.0 * v) )
805
+ . then_scope :: < _ , ( ) > ( ScopeSettings :: default ( ) , |scope, builder| {
806
+ scope. input . chain ( builder)
807
+ . unzip_build ( (
808
+ |chain : Chain < f64 > | {
809
+ chain
810
+ . map_block ( |v| ( v, 10.0 ) )
811
+ . map_block ( add)
812
+ . connect ( scope. terminate ) ;
813
+ } ,
814
+ |chain : Chain < f64 > | {
815
+ chain
816
+ . map_block ( |value|
817
+ WaitRequest {
818
+ duration : std:: time:: Duration :: from_secs_f64 ( 0.01 ) ,
819
+ value,
820
+ }
821
+ )
822
+ . map_async ( wait)
823
+ . connect ( scope. terminate ) ;
824
+ } ,
825
+ ) ) ;
826
+ } )
827
+ . connect ( scope. terminate ) ;
828
+ } ) ;
829
829
830
- // context.run_while_pending(&mut promise);
831
- // assert_eq!(promise.peek().available().copied(), Some(15.0));
832
- // }
830
+
831
+ let mut promise = context. build ( |commands| {
832
+ commands
833
+ . request ( ( 2.0 , 3.0 ) , workflow)
834
+ . take_response ( )
835
+ } ) ;
836
+
837
+ context. run_while_pending ( & mut promise) ;
838
+ assert_eq ! ( promise. peek( ) . available( ) . copied( ) , Some ( 15.0 ) ) ;
839
+ assert ! ( context. no_unhandled_errors( ) ) ;
840
+ }
833
841
834
842
// #[test]
835
843
// fn test_dispose_on_cancel() {
0 commit comments