diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b95fdee..dbb66107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + - `FillValueMetadata::try_as_uint/int` can both now handle `FillValueMetadata::Uint/Int` + ## [0.5.0] - 2023-10-08 ### Added diff --git a/Cargo.toml b/Cargo.toml index f09781da..fe923de3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zarrs" description = "A library for the Zarr V3 storage format for multidimensional arrays and metadata" -version = "0.5.0" +version = "0.5.1" authors = ["Lachlan Deakin "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/src/array/fill_value_metadata.rs b/src/array/fill_value_metadata.rs index e61d261d..1e323dc9 100644 --- a/src/array/fill_value_metadata.rs +++ b/src/array/fill_value_metadata.rs @@ -18,7 +18,7 @@ pub enum FillValueMetadata { /// A boolean value. Bool(bool), /// An unsigned integer. - Uint(u64), + Uint(u64), // FIXME: UInt for consistency? /// A signed integer. Int(i64), /// A float. @@ -132,25 +132,31 @@ impl FillValueMetadata { } } - /// Convert the fill value an int. + /// Convert the fill value to int. #[must_use] - pub fn try_as_int>(&self) -> Option { + pub fn try_as_int + std::convert::TryFrom>( + &self, + ) -> Option { match self { FillValueMetadata::Int(int) => T::try_from(*int).ok(), + FillValueMetadata::Uint(uint) => T::try_from(*uint).ok(), _ => None, } } - /// Convert the fill value a uint. + /// Convert the fill value to uint. #[must_use] - pub fn try_as_uint>(&self) -> Option { + pub fn try_as_uint + std::convert::TryFrom>( + &self, + ) -> Option { match self { + FillValueMetadata::Int(int) => T::try_from(*int).ok(), FillValueMetadata::Uint(uint) => T::try_from(*uint).ok(), _ => None, } } - /// Convert the fill value a float. + /// Convert the fill value to float. #[must_use] pub fn try_as_float(&self) -> Option { match self {