Type error when combining streams

I’m trying to write a chess clock library. The clock will run in another thread, and take unit-type signals on an mpsc channel to trigger the clock switching to the next player. If the clock expires, it sends a unit-type message back on another channel. Internally, my plan is to use tokio::timer and perform a select-like combination with the receiving channel chan.recv().into_stream(). Here’s what the code looks like:

use futures::future::{ok, err, FutureResult};
use std::time::{Duration, Instant};

    fn launch_timer(&mut self, duration: Duration) {
          let now = Instant::now();
          let expiry_time = now + duration;
       
          let future_expire =
              tokio::timer::Delay::new(expiry_time)
                  .then(|_| -> FutureResult<(), ()> { ok(()) })
                  .map_err(|_| -> FutureResult<(), ()> { err(()) })
                  .into_stream();
          StreamNext::new(self.next_rx, future_expire); // next_rx: futures::sync::mpsc::Receiver<()>

StreamNext is a custom combinator that selects the next output from either stream, taken from here. The two streams must have the same error type, which I tried to achieve with the map_err call. However, I get the following error:

error[E0271]: type mismatch resolving `<futures::IntoStream<futures::MapErr<futures::Then<tokio::timer::Delay, futures::FutureResult<(), ()>, [closure@src/chess_clock.rs:65:23: 65:61]>, [closure@src/chess_clock.rs:66:26: 66:65]>> as futures::Stream>::Error == ()`
  --> src/chess_clock.rs:70:9                                                     
   |                                                                              
70 |         StreamNext::new(self.next_rx, future_expire);                        
   |         ^^^^^^^^^^^^^^^ expected struct `futures::FutureResult`, found ()    
   |                                                                              
   = note: expected type `futures::FutureResult<(), ()>`                          
              found type `()`                             

Can you help me understand this error? It looks like map_err hasn’t caused the future to produce a FutureResult. I would also appreciate comments on my proposed design for this library, but that’s secondary.

The map_err call should return (), not FutureResult<(), ()>, so:

.map_err(|_| ())

Yes, that’s it. Thanks!