From 2e376eda55dffc4b568ee8e305a6521e8a93fdfe Mon Sep 17 00:00:00 2001 From: Luca Trevisani Date: Tue, 19 Dec 2023 23:34:09 +0100 Subject: [PATCH] Rename `DataType` methods `as_f64` `as_i64` into `as_float` `as_int` --- README.md | 5 ++--- src/datatype.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ec28bede..317bed5a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ where D: serde::Deserializer<'de>, { let data_type = calamine::DataType::deserialize(deserializer)?; - if let Some(float) = data_type.as_f64() { + if let Some(float) = data_type.as_float() { Ok(Some(float)) } else { Ok(None) @@ -85,7 +85,6 @@ fn main() -> Result<(), Box> { } ``` - ### Reader: Simple ```rust @@ -160,7 +159,7 @@ for s in sheets { ## Features -- `dates`: Add date related fn to `DataType`. +- `dates`: Add date related fn to `DataType`. - `picture`: Extract picture data. ### Others diff --git a/src/datatype.rs b/src/datatype.rs index f3d508e2..bf55c0a2 100644 --- a/src/datatype.rs +++ b/src/datatype.rs @@ -105,7 +105,7 @@ impl DataType { } } /// Try converting data type into an int - pub fn as_i64(&self) -> Option { + pub fn as_int(&self) -> Option { match self { DataType::Int(v) => Some(*v), DataType::Float(v) => Some(*v as i64), @@ -114,7 +114,7 @@ impl DataType { } } /// Try converting data type into a float - pub fn as_f64(&self) -> Option { + pub fn as_float(&self) -> Option { match self { DataType::Int(v) => Some(*v as f64), DataType::Float(v) => Some(*v),