Hacker News new | past | comments | ask | show | jobs | submit login

Agree, I don't know if it's that useful for `Result<T>`, but for `Option<T>`, there has been a couple of times I've written

  if foo.is_none() {
    return;
  }
  let foo = foo.unwrap()
Now I can do simply

  let Some(foo_unwrapped) = foo else {
    return;
  }
which is prettier than the `if let (...)` to just unwrap it IMO.



Without let-else, you could write that as:

    let foo_unwrapped = match foo {
      Some(foo_unwrapped) => foo_unwrapped,
      None => return,
    };
Not as pretty, but you don't have to unwrap.




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

Search: