Error code E0054

It is not allowed to cast to a bool.

Erroneous code example:

let x = 5;

// Not allowed, won't compile
let x_is_nonzero = x as bool;
Run

If you are trying to cast a numeric type to a bool, you can compare it with zero instead:

let x = 5;

// Ok
let x_is_nonzero = x != 0;
Run

Back to list of error codes