Skip to content

Commit

Permalink
impl ToPrimitive
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Dec 12, 2024
1 parent df0b82c commit db45e97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["rbdc-pool-fast","rbdc-sqlite","rbdc-mysql","rbdc-pg","rbdc-mssql", "example"]
[package]
name = "rbdc"
version = "4.5.43"
version = "4.5.44"
edition = "2021"
description = "The Rust SQL Toolkit and ORM Library. An async, pure Rust SQL crate featuring compile-time Dynamic SQL"
readme = "Readme.md"
Expand Down
21 changes: 20 additions & 1 deletion src/types/decimal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]

use crate::Error;
use bigdecimal::{BigDecimal, FromPrimitive};
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use rbs::Value;
use serde::Deserializer;
use std::cmp::Ordering;
Expand Down Expand Up @@ -181,6 +181,25 @@ impl FromStr for Decimal {
}
}

impl ToPrimitive for Decimal{
fn to_i64(&self) -> Option<i64> {
self.0.to_i64()
}
fn to_i128(&self) -> Option<i128> {
self.0.to_i128()
}
fn to_u64(&self) -> Option<u64> {
self.0.to_u64()
}
fn to_u128(&self) -> Option<u128> {
self.0.to_u128()
}

fn to_f64(&self) -> Option<f64> {
self.0.to_f64()
}
}

impl Default for Decimal {
fn default() -> Self {
Decimal(BigDecimal::from(0))
Expand Down

0 comments on commit db45e97

Please sign in to comment.