Skip to content
ZOLO / TE841 Type · error

numeric cast policy is incompatible with the source or target

A numeric `cast` policy applies only to the conversion family it names — `.wrap` is defined only for integer-to-integer conversion, while `.trunc`/`.floor`/`.ceil`/`.nearest_even` convert floating-point values. Choose a compatible policy, or use `as?` when only exact values are accepted.

Why this fires

A numeric cast policy only applies to the conversion family it names. For example, .wrap is defined only for integer-to-integer conversion, while .trunc, .floor, .ceil, and .nearest_even convert floating-point values.

let value = 3.5.cast::<i32>(.wrap) // error[TE841]

Fix it

Choose a compatible policy, or use as? when only exact values are accepted:

let truncated = 3.5.cast::<i32>(.trunc)?
let exact = 3.5 as? i32

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br