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