Skip to content

Commit

Permalink
Rename DataType methods as_f64 as_i64 into as_float as_int
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatrv committed Dec 19, 2023
1 parent ad57593 commit 2e376ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -85,7 +85,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```


### Reader: Simple

```rust
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl DataType {
}
}
/// Try converting data type into an int
pub fn as_i64(&self) -> Option<i64> {
pub fn as_int(&self) -> Option<i64> {
match self {
DataType::Int(v) => Some(*v),
DataType::Float(v) => Some(*v as i64),
Expand All @@ -114,7 +114,7 @@ impl DataType {
}
}
/// Try converting data type into a float
pub fn as_f64(&self) -> Option<f64> {
pub fn as_float(&self) -> Option<f64> {
match self {
DataType::Int(v) => Some(*v as f64),
DataType::Float(v) => Some(*v),
Expand Down

0 comments on commit 2e376ed

Please sign in to comment.