7900 shaares
161 private links
161 private links
anyhow
works well.
A lot of confusion around unwrap(), I think, comes from well meaning folks saying things like “don’t use unwrap(),” when what they actually mean is “don’t use panicking as an error handling strategy.”
Of course, when possible, pushing runtime invariants to compile-time invariants is generally preferred. Then one doesn’t have to worry about unwrap() or assert! or anything else. The invariant is maintained by virtue of the program compiling. Rust is exceptionally well suited to pushing a lot of runtime invariants to compile-time invariants. Indeed, its entire mechanism of maintaining memory safety depends crucially on it.