Skip to main content

try_decimal_or_warn

Function try_decimal_or_warn 

Source
pub fn try_decimal_or_warn(
    value: f64,
    field_name: impl Display,
) -> Option<Decimal>
Expand description

Convert an IB f64 to a Decimal: None, with a warning, when it is not a finite number that fits, so that a caller can keep it unknown rather than read it as zero.

field_name names the value in the warning; a format_args! can add context, such as the order, without formatting it unless the warning fires.