Error codes

E0254: else e => on an optional

In a terminal: auk explain E0254 prints this page.

On this page

else e => ... binds the error of a T!. A T? has no error, just a missing value, so there is nothing to bind: write a plain else fallback.

Wrong#

auk
fn main() {
  let x = [1].first() else e => 0
  print(x)
}

Fixed#

auk
fn main() {
  let x = [1].first() else 0
  print(x)
}

Common causes#

  • Treating an optional lookup (first, find, get) as fallible.
  • Copying an error-handling pattern from a T! call.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page