Macro Dec

Source
Dec!() { /* proc-macro */ }
Expand description

Macro used to convert a number literal into a Decimal<P>.

The literal must be in the form [+|-]<int>[.<frac>][<e|E>[+|-]<exp>] or [+|-].<frac>[<e|E>[+|-]<exp>].

P is determined by the number of fractional digits minus the value of the signed exponent. It must not exceed the constant MAX_PREC.

The resulting value must not exceed the limits given by Decimal::<P>::MIN and Decimal::<P>::MAX.

§Panics

The macro panics if the conditions listed above are not met!

§Examples

let d = Dec!(17.5);
assert_eq!(d.to_string(), "17.5");

let d = Dec!(-170.5e-2);
assert_eq!(d.to_string(), "-1.705");