Skip to content

Commit

Permalink
f64 retrieval from typed dict entries
Browse files Browse the repository at this point in the history
  • Loading branch information
matko committed Oct 18, 2023
1 parent 4d40d8a commit 4296aed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/structure/tfc/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ impl TypedDictEntry {
Q::from_lexical(self.entry.as_buf()).into()
}

#[doc(hidden)]
pub fn as_i32(&self) -> Option<i32> {
match self.datatype {
Datatype::Int32 => Some(self.as_casted_val::<i32, i32>()),
Datatype::Int32 => Some(self.as_val::<i32, i32>()),
Datatype::UInt8 => Some(self.as_casted_val::<i32, u8>()),
Datatype::Int8 => Some(self.as_casted_val::<i32, i8>()),
Datatype::UInt16 => Some(self.as_casted_val::<i32, u16>()),
Expand All @@ -55,6 +56,15 @@ impl TypedDictEntry {
}
}

#[doc(hidden)]
pub fn as_f64(&self) -> Option<f64> {
match self.datatype {
Datatype::Float64 => Some(self.as_val::<f64, f64>()),
Datatype::Float32 => Some(self.as_casted_val::<f64, f32>()),
_ => None,
}
}

pub fn datatype(&self) -> Datatype {
self.datatype
}
Expand Down

0 comments on commit 4296aed

Please sign in to comment.