sea_query/value/
with_bigdecimal.rs1use super::*;
2
3type_to_box_value!(BigDecimal, BigDecimal, Decimal(None));
4
5impl Value {
6 pub fn is_big_decimal(&self) -> bool {
7 matches!(self, Self::BigDecimal(_))
8 }
9
10 pub fn as_ref_big_decimal(&self) -> Option<&BigDecimal> {
11 match self {
12 Self::BigDecimal(v) => v.as_ref().map(|x| x.as_ref()),
13 _ => panic!("not Value::BigDecimal"),
14 }
15 }
16
17 pub fn big_decimal_to_f64(&self) -> Option<f64> {
18 use bigdecimal::ToPrimitive;
19 self.as_ref_big_decimal().map(|d| d.to_f64().unwrap())
20 }
21}