From d5172489ccf5c1271d1f8f93dff7ffc9924f64af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jun 2024 11:49:01 +0200 Subject: [PATCH] small update for unsigned byte field --- CHANGELOG.md | 10 ++++++++++ src/util.rs | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7bfe3d..13d8485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +# [v0.12.0] 2024-06-06 + +## Added + +- `Default` impl for `GenericUnsignedByteField<()>` (also called `UnsignedByteFieldEmpty`) + +## Changed + +- Removed `Into` type constraint for `GenericUnsignedByteField` + # [v0.11.2] 2024-05-19 - Bumped MSRV to 1.68.2 diff --git a/src/util.rs b/src/util.rs index da80792..17dd92e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -242,7 +242,7 @@ impl UnsignedEnum for UnsignedByteField { #[derive(Debug, Copy, Clone, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub struct GenericUnsignedByteField> { +pub struct GenericUnsignedByteField { value: TYPE, } @@ -290,6 +290,14 @@ pub type UbfU16 = UnsignedByteFieldU16; pub type UbfU32 = UnsignedByteFieldU32; pub type UbfU64 = UnsignedByteFieldU64; +impl Default for GenericUnsignedByteField<()> { + fn default() -> Self { + Self { + value: Default::default(), + } + } +} + impl From for UnsignedByteField { fn from(value: UnsignedByteFieldU8) -> Self { Self::new(1, value.value as u64)