Closed
Description
What it does
Check if the value that is_empty
is called on is immutable and set to a non-empty value (e.g. a string literal), in which case it warns that the code will always evaluate to false
. Of course, the opposite could be checked for values that are always set as empty.
Advantage
- Removing unreachable code
Drawbacks
No response
Example
let value = "Non-empty string";
if value.is_empty() {
// this is will never execute, since value is always non-empty
println!("value is empty");
}
Could be written as:
let value = "Non-empty string";