Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I used it frequently when mixing `Result` with `Future`. For example,

  fn do_something() -> Box<Future<Item=(), Error=Error>> {
    let val = match do_result() {
      Ok(x) => x,
      Err(e) => return Box::new(err(e.into())),
    };
    // do something with `val`
    unimplemented!();
  }


If you want to cut down on lines, this is equivalent:

    let val = do_result().map_err(|e| Box::new(err(e.into())))?;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: