fn with_flush() {
    let (tx, rx) = oneshot::channel();
    let mut block = Box::new(rx) as Box<Future<Item = _, Error = _>>;
    let mut sink = Vec::new().with(|elem| {
        mem::replace(&mut block, Box::new(ok(())))
            .map(move |_| elem + 1).map_err(|_| -> Never { panic!() })
    });

    assert_eq!(sink.start_send(0), Ok(()));

    flag_cx(|flag, cx| {
        let mut task = sink.flush();
        assert!(task.poll(cx).unwrap().is_pending());
        tx.send(()).unwrap();
        assert!(flag.get());

        let sink = match task.poll(cx).unwrap() {
            Poll::Ready(sink) => sink,
            _ => panic!()
        };

        assert_eq!(block_on(sink.send(1)).unwrap().get_ref(), &[1, 2]);
    })
}
// test `flush` by using `with` to make the first insertion into a sink block
// until a oneshot is completed
test `flush` by using `with` to make the first insertion into a sink block
until a oneshot is completed
test ` flush ` by using ` with ` to make the first insertion into a sink block until a oneshot is completed
fn with_flush() {
    let (tx, rx) = oneshot::channel();
    let mut block = Box::new(rx) as Box<Future<Item = _, Error = _>>;
    let mut sink = Vec::new().with(|elem| {
        mem::replace(&mut block, Box::new(ok(())))
            .map(move |_| elem + 1).map_err(|_| -> Never { panic!() })
    });
    assert_eq!(sink.start_send(0), Ok(()));
    flag_cx(|flag, cx| {
        let mut task = sink.flush();
        assert!(task.poll(cx).unwrap().is_pending());
        tx.send(()).unwrap();
        assert!(flag.get());
        let sink = match task.poll(cx).unwrap() {
            Poll::Ready(sink) => sink,
            _ => panic!()
        };
        assert_eq!(block_on(sink.send(1)).unwrap().get_ref(), &[1, 2]);
    })
}
fn with_flush ( ) { let ( tx , rx ) = oneshot :: channel ( ) ; let mut block = Box :: new ( rx ) as Box < Future < Item = _ , Error = _ > > ; let mut sink = Vec :: new ( ) . with ( | elem | { mem :: replace ( & mut block , Box :: new ( ok ( ( ) ) ) ) . map ( move | _ | elem + 1 ) . map_err ( | _ | -> Never { panic ! ( ) } ) } ) ; assert_eq ! ( sink start_send ( 0 ) Ok ( ( ) ) ) ; flag_cx ( | flag , cx | { let mut task = sink . flush ( ) ; assert ! ( task poll ( cx ) unwrap ( ) is_pending ( ) ) ; tx . send ( ( ) ) . unwrap ( ) ; assert ! ( flag get ( ) ) ; let sink = match task . poll ( cx ) . unwrap ( ) { Poll :: Ready ( sink ) => sink , _ => panic ! ( ) } ; assert_eq ! ( block_on ( sink send ( 1 ) ) unwrap ( ) get_ref ( ) [ 1 2 ] ) ; } ) }
test `flush` by using `with` to make the first insertion into a sink block
until a oneshot is completed
test ` flush ` by using ` with ` to make the first insertion into a sink block until a oneshot is completed