fn multishot_notify<F>(f: F, expect: Result<i32, RecvError>)
    where
        F: FnOnce(Sender<i32>) + Send + Copy + 'static,
    {
        let test_waker = Arc::new(TestWaker::new());
        let waker = test_waker.clone().into();
        let mut cx = Context::from_waker(&waker);
        let mut receiver: Receiver<i32> = Receiver::new();

        // Consume sender before polling.
        {
            let sender = receiver.sender().expect("could not create sender");
            let mut fut = receiver.recv();
            let mut fut = Pin::new(&mut fut);

            spawn_and_join(move || f(sender));
            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(test_waker.take_count(), 0);
            assert_eq!(res, Poll::Ready(expect));
        }

        // Consume sender after polling.
        {
            let sender = receiver.sender().expect("could not create sender");
            let mut fut = receiver.recv();
            let mut fut = Pin::new(&mut fut);

            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(res, Poll::Pending);
            spawn_and_join(move || f(sender));
            assert_eq!(test_waker.take_count(), 1);
            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(res, Poll::Ready(expect));
        }
    }
// Executes a closure consuming the sender and checks the result of the
// completed future.
Executes a closure consuming the sender and checks the result of the
completed future.
Executes a closure consuming the sender and checks the result of the completed future .
fn multishot_notify<F>(f: F, expect: Result<i32, RecvError>)
    where
        F: FnOnce(Sender<i32>) + Send + Copy + 'static,
    {
        let test_waker = Arc::new(TestWaker::new());
        let waker = test_waker.clone().into();
        let mut cx = Context::from_waker(&waker);
        let mut receiver: Receiver<i32> = Receiver::new();
        // Consume sender before polling.
        {
            let sender = receiver.sender().expect("could not create sender");
            let mut fut = receiver.recv();
            let mut fut = Pin::new(&mut fut);
            spawn_and_join(move || f(sender));
            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(test_waker.take_count(), 0);
            assert_eq!(res, Poll::Ready(expect));
        }
        // Consume sender after polling.
        {
            let sender = receiver.sender().expect("could not create sender");
            let mut fut = receiver.recv();
            let mut fut = Pin::new(&mut fut);
            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(res, Poll::Pending);
            spawn_and_join(move || f(sender));
            assert_eq!(test_waker.take_count(), 1);
            let res = fut.as_mut().poll(&mut cx);
            assert_eq!(res, Poll::Ready(expect));
        }
    }
fn multishot_notify < F > ( f : F , expect : Result < i32 , RecvError > ) where F : FnOnce ( Sender < i32 > ) + Send + Copy + ' static , { let test_waker = Arc :: new ( TestWaker :: new ( ) ) ; let waker = test_waker . clone ( ) . into ( ) ; let mut cx = Context :: from_waker ( & waker ) ; let mut receiver : Receiver < i32 > = Receiver :: new ( ) ; // Consume sender before polling. { let sender = receiver . sender ( ) . expect ( " " ) ; let mut fut = receiver . recv ( ) ; let mut fut = Pin :: new ( & mut fut ) ; spawn_and_join ( move | | f ( sender ) ) ; let res = fut . as_mut ( ) . poll ( & mut cx ) ; assert_eq ! ( test_waker take_count ( ) 0 ) ; assert_eq ! ( res Poll Ready ( expect ) ) ; } // Consume sender after polling. { let sender = receiver . sender ( ) . expect ( " " ) ; let mut fut = receiver . recv ( ) ; let mut fut = Pin :: new ( & mut fut ) ; let res = fut . as_mut ( ) . poll ( & mut cx ) ; assert_eq ! ( res Poll Pending ) ; spawn_and_join ( move | | f ( sender ) ) ; assert_eq ! ( test_waker take_count ( ) 1 ) ; let res = fut . as_mut ( ) . poll ( & mut cx ) ; assert_eq ! ( res Poll Ready ( expect ) ) ; } }
Executes a closure consuming the sender and checks the result of the
completed future.
Executes a closure consuming the sender and checks the result of the completed future .
f
F
expect
Result<i32, RecvError>