From 4296aedbad5011c4757aa32766068ad5854baaa3 Mon Sep 17 00:00:00 2001 From: Matthijs van Otterdijk Date: Wed, 18 Oct 2023 16:30:49 +0200 Subject: [PATCH] f64 retrieval from typed dict entries --- src/structure/tfc/typed.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/structure/tfc/typed.rs b/src/structure/tfc/typed.rs index 002943b..44da190 100644 --- a/src/structure/tfc/typed.rs +++ b/src/structure/tfc/typed.rs @@ -44,9 +44,10 @@ impl TypedDictEntry { Q::from_lexical(self.entry.as_buf()).into() } + #[doc(hidden)] pub fn as_i32(&self) -> Option { match self.datatype { - Datatype::Int32 => Some(self.as_casted_val::()), + Datatype::Int32 => Some(self.as_val::()), Datatype::UInt8 => Some(self.as_casted_val::()), Datatype::Int8 => Some(self.as_casted_val::()), Datatype::UInt16 => Some(self.as_casted_val::()), @@ -55,6 +56,15 @@ impl TypedDictEntry { } } + #[doc(hidden)] + pub fn as_f64(&self) -> Option { + match self.datatype { + Datatype::Float64 => Some(self.as_val::()), + Datatype::Float32 => Some(self.as_casted_val::()), + _ => None, + } + } + pub fn datatype(&self) -> Datatype { self.datatype }