E0048
Error
?? on a value that is not optional
ErrorThe left side of ?? is the optional that may be None. The right side is the value to use then.
Why
?? supplies a default for a missing value. A value that is not optional is never missing, so the default would never be used.
Broken
fn main() {
let n = 5
print(n ?? 0)
}
What sisu says
error[E0048]: the left side of `??` is not optional --> E0048.sisu:3:11 | 3 | print(n ?? 0) | ^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0048
Fixed
fn main() {
let n: i64? = 5
print(n ?? 0)
}
Sisu