Skip to content

Commit f26c8a9

Browse files
authored
Merge pull request #48 from Vam-Jam/decimal-deref
Decimal implements Deref
2 parents 74f49f6 + a020f16 commit f26c8a9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

shopify_function/src/scalars/decimal.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use serde::{Deserialize, Serialize};
2-
use std::str::FromStr;
2+
use std::{ops::Deref, str::FromStr};
33

44
/// Convenience wrapper for converting between Shopify's `Decimal` scalar, which
55
/// is serialized as a `String`, and Rust's `f64`.
@@ -15,6 +15,14 @@ impl Decimal {
1515
}
1616
}
1717

18+
impl Deref for Decimal {
19+
type Target = f64;
20+
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
1826
impl TryFrom<String> for Decimal {
1927
type Error = std::num::ParseFloatError;
2028

0 commit comments

Comments
 (0)