Re:Google broke a conditional statement that verifies passwo...
by wyager on Thursday July 22, 2021 @04:40PM
(#27924027)
The most general solution here is to use algebraic types and pattern match on the value being “None” or “Some data”.
[ Parent
| on HN ]
Re:Google broke a conditional statement that verifies passwo...
by tialaramex on Thursday July 22, 2021 @09:28PM
(#27926295)
Certainly 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.
Re:Google broke a conditional statement that verifies passwo...
by Cthulhu_ on Friday July 23, 2021 @04:33AM
(#27928509)
It'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.