typst_template/convert/rust_decimal.rs
1use typst::foundations::{Decimal, Value};
2
3use crate::ToValue;
4
5impl ToValue for rust_decimal::Decimal {
6 fn into_value(self) -> Value {
7 // Typst has its own 128-bit decimal; round-trip through the string form
8 // to preserve the exact value.
9 let decimal: Decimal = self
10 .to_string()
11 .parse()
12 .expect("decimal string is well-formed");
13 Value::Decimal(decimal)
14 }
15}