| ▲ | echelon an hour ago | ||||||||||||||||||||||
A lot of stuff should be done about the awful unwrap family of methods. A few ideas: - It should not compile in production Rust code - It should only be usable within unsafe blocks - It should require explicit "safe" annotation from the engineer. Though this is subject to drift and become erroneous. - It should be possible to ban the use of unsafe in dependencies and transitive dependencies within Cargo. | |||||||||||||||||||||||
| ▲ | kibwen an hour ago | parent [-] | ||||||||||||||||||||||
The `unsafe` keyword means something specific in Rust, and panicking isn't unsafe by Rust's definition. Sometimes avoiding partial functions just isn't feasible, and an unwrap (or whatever you want to call the method) is a way of providing a (runtime-checked) proof to the compiler that the function is actually total. | |||||||||||||||||||||||
| |||||||||||||||||||||||