? unwraps a value that may be an error or missing, passing the bad case up. This value is a
plain type that can't fail, so there is nothing for ? to do.
Wrong#
fn main() {
let n = "abc".len()?
print(n)
}Fixed#
fn main() {
let n = "abc".len()
print(n)
}Common causes#
?added by habit to a call that can't fail: remove it.- A function whose return type changed from
T!toT, leaving?at its call sites.