Skip to content
ZOLO / TE836 Type · error

checked cast can never succeed or has no exact implementation

`value as? T` promises an exact, runtime-checked conversion, but the source and destination types have no value-preserving checked path — for example parsing text is not casting. Use `parse`, `try_into`, or a numeric cast policy instead.

Why this fires

value as? T promises an exact, runtime-checked conversion. The diagnostic fires when the source and destination have no value-preserving checked path.

let value = "42" as? int // error[TE836]: parsing is not casting

Fix it

Use parse for text, try_into for domain values, or choose a numeric cast policy when information may be discarded.

let value = "42".parse::<int>()?

See also

  • TE835 — invalid total cast.
  • TE837 — lossy numeric cast.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br