From 33837e4c8e9cce89fc426352b66a2c752c3da6b9 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Fri, 4 Oct 2024 13:47:07 +0200 Subject: [PATCH 1/2] Derive Default for Sealed --- crates/primitives/src/sealed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/primitives/src/sealed.rs b/crates/primitives/src/sealed.rs index f69ded2d6b..eb2a3d28da 100644 --- a/crates/primitives/src/sealed.rs +++ b/crates/primitives/src/sealed.rs @@ -4,7 +4,7 @@ use crate::B256; /// /// We do not implement any specific hashing algorithm here. Instead types /// implement the [`Sealable`] trait to provide define their own hash. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Default, Copy, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Sealed { /// The inner item From a8f76e9586b1933773dca496cf2bb45d53375932 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Fri, 4 Oct 2024 19:32:43 +0200 Subject: [PATCH 2/2] Manual impl Default for Sealed --- crates/primitives/src/sealed.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/primitives/src/sealed.rs b/crates/primitives/src/sealed.rs index eb2a3d28da..22e3d21c6c 100644 --- a/crates/primitives/src/sealed.rs +++ b/crates/primitives/src/sealed.rs @@ -4,7 +4,7 @@ use crate::B256; /// /// We do not implement any specific hashing algorithm here. Instead types /// implement the [`Sealable`] trait to provide define their own hash. -#[derive(Clone, Default, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Sealed { /// The inner item @@ -67,6 +67,15 @@ impl Sealed { } } +impl Default for Sealed +where + T: Sealable + Default, +{ + fn default() -> Self { + T::default().seal_slow() + } +} + /// Sealeable objects. pub trait Sealable: Sized { /// Calculate the seal hash, this may be slow.