2 ms·
The most general solution here is to use algebraic types and pattern match on the value being “None” or “Some data”.
by wyager 5y ago
The most general solution here is to use algebraic types and pattern match on the value being “None” or “Some data”.
- tialaramex 5y agoCertainly I find if (key_data_.has_value() && !key_data_->label().empty()) return key_data_->label(); to be less readable than: if let Some(label) = key_data_ { label } It's notable that people complain Rust adds too many odd punctuation marks, and yet in this example it's C++ with an exclamation mark, question marks, and two different structure member operators (dot and arrow) while Rust just does the pattern match.
- Cthulhu_ 5y agoIt's not, because that would involve re-engineering and re-writing millions of lines of code. The simpler solution is to fix this gap in their automated testing. Another one is to configure a linter to error on bitwise operations on boolean values.