From a020f16546e4c914dd9636e9fa9a295ccb4fd6ed Mon Sep 17 00:00:00 2001 From: Vam-Jam Date: Tue, 17 Oct 2023 15:05:58 +0100 Subject: [PATCH] Decimal implements Deref --- shopify_function/src/scalars/decimal.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shopify_function/src/scalars/decimal.rs b/shopify_function/src/scalars/decimal.rs index 403ff0a..00e2260 100644 --- a/shopify_function/src/scalars/decimal.rs +++ b/shopify_function/src/scalars/decimal.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use std::str::FromStr; +use std::{ops::Deref, str::FromStr}; /// Convenience wrapper for converting between Shopify's `Decimal` scalar, which /// is serialized as a `String`, and Rust's `f64`. @@ -15,6 +15,14 @@ impl Decimal { } } +impl Deref for Decimal { + type Target = f64; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + impl TryFrom for Decimal { type Error = std::num::ParseFloatError;