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