Returning hyper::MapErr and Result for future

I am trying to use a futures stream for_each, but in the future I am making a request only if the url is valid:

    let (tx, rx) = channel::<DownloadRequest>(0);
    let downloader = thread::spawn(move || {
        let mut core = Core::new().unwrap();
        let handle = &core.handle();
        let hyper_client = Client::configure()
            .connector(HttpsConnector::new(10, handle).unwrap())

        let downloads = rx.for_each(move |chunk| {
            let DownloadRequest { url, offset } = chunk.clone();

            // TODO: handle errors
            // let uri = url.parse().unwrap();
            if let Some(uri) = url.parse().ok() {
                let req = Request::new(Method::Get, uri);

                    .and_then(move |success| {
                    .map_err(move |err| {
                        info!("error download: {:?}", err);

The compiler doesn’t like that in my two branches I’m returning a MapErr and a Result, even though they both satisfy the IntoFuture trait that is required by for_each. It works fine if i just use the uri.parse().unwrap() and just return the MapErr. How can i properly error check this? Thank you!

Take a look at Either - it allows you to return two different types as long as they’re both Futures that yield same error and item type.