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

If the `.unwrap()` was replaced with

1:

  ?
2:

  map_err, or, or_else, etc.
3:

  match ... { 
    Ok(..) => {}, 
    Err(..) => {},
  }
4:

  if let ... {
  } 
Then it would have been idiomatic Rust code and wouldn't have failed at all.

The function signature returned a `Result<(), (ErrorFlags, i32)>`

Seems like it should have returned an Err((ErrorFlags, i32)) here. Case 2 or 3 above would have done nicely.

Removing unwrap() from Rust would have forced the proper handling of the function call and would have prevented this.

Unwrap() is Rust's original sin.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: