3 ms·
Yet many Rust code bases are littered with .unwrap(), which undoes that benefit.
by yencabulator 5y ago
Yet many Rust code bases are littered with .unwrap(), which undoes that benefit.
- Ar-Curunir 5y agobut it's explicit; you can easily tell which lines of code will panic.
- Freaky 5y agoA great deal of the benefit of Option comes from where it isn't used - you know most things can't be null and simply don't have to think about the possibility. unwrap() bugs are annoying, yes, but at the end of the day they're just a fancy assert(), helpfully spelled out in the code and confined to bits of it where the value is Option<T>. This is a much better situation than a language where nulls can in principle turn up anywhere.