News for hackers. Stuff that matters.
Re:Rust should not have provided `unwrap` by oxff on Friday July 15, 2022 @01:18PM (#32110508)
Sometimes you don't want to use `?` though, not every function is made to return a Result / Option.
Re:Rust should not have provided `unwrap` by mcronce on Friday July 15, 2022 @02:31PM (#32111340)
If your function is fallible, your function is fallible - it's up to you to decide whether that means returning Result or panicking. If you want your function to be infallible, while itself calling a fallible function, you have to handle the error cases from your callees - you have `.unwrap_or_default()`, `.unwrap_or_else()`, `.unwrap_or()`, and simple `match` all in your toolbox to do this.
Re:Rust should not have provided `unwrap` by dymk on Friday July 15, 2022 @01:24PM (#32110594)
In that case, you use `unwrap`, or you manually convert it into your return type, or you provide an `impl Try` [0] for your return type once that feature becomes stable (already possible if you're on nightly)

[0] - https://github.com/rust-lang/rust/issues/84277