E0045
Error
is used to test for None
Erroris tests identity: whether two references refer to the same object. None is no object, so is does not apply to it.
Why
Testing for None is a comparison of values, written with ==.
Broken
class Node {
next: Node?
}
fn main() {
let n = Node(next: None)
print(n.next is None)
}
What sisu says
error[E0045]: `is` tests identity, and `None` is not an object --> E0045.sisu:7:11 | 7 | print(n.next is None) | ^^^^^^^^^^^^^^ | = help: use `n.next == None` sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0045
Fixed
class Node {
next: Node?
}
fn main() {
let n = Node(next: None)
print(n.next == None)
}
Sisu