Re:Speeding Up the Rust Compiler
by tov_objorkin on Wednesday December 11, 2019 @06:38AM
(#21761550)
unwrap() or expect() unconditionally smash program execution in case of error.
Properly written program should handle such errors or use unwrap_or_* as fallback.
The point is that unwrap/unsafe is breaking safety rules, user writing one know what hes doing or just don't bothering.
[ Parent
| on HN ]
Re:Speeding Up the Rust Compiler
by jashmatthews on Wednesday December 11, 2019 @06:56AM
(#21761639)
Unwrap and expect don’t violate any safety rules! If they did you’d need to wrap it in an unsafe block.
Re:Speeding Up the Rust Compiler
by tov_objorkin on Wednesday December 11, 2019 @08:52AM
(#21762271)
You're technically right, i mean if user aim for durable code then using unwrap is not desired behavior most of the time.
For example pointer deference in C is implicit operation.
In Rust user must choose explicitly how to handle Option/Result.
Even if using unwrap not so harmful as using unsafe and didn't violate rules this is our deliberate choose to break "end-user safety".