From 0f84677e9b28ca2b2fc5de94bb68d372f3905678 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Fri, 4 Oct 2024 13:52:19 +0200 Subject: [PATCH] Derive Deref for Sealed --- crates/primitives/Cargo.toml | 1 + crates/primitives/src/sealed.rs | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index ee8786acba..813baa616d 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -43,6 +43,7 @@ derive_more = { workspace = true, features = [ "into", "into_iterator", "display", + "deref", ] } paste.workspace = true diff --git a/crates/primitives/src/sealed.rs b/crates/primitives/src/sealed.rs index f69ded2d6b..54a1318b66 100644 --- a/crates/primitives/src/sealed.rs +++ b/crates/primitives/src/sealed.rs @@ -1,26 +1,21 @@ +use derive_more::Deref; + use crate::B256; /// A consensus hashable item, with its memoized hash. /// /// 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, Copy, Debug, PartialEq, Eq, Hash, Deref)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Sealed { /// The inner item + #[deref] inner: T, /// Its hash. seal: B256, } -impl core::ops::Deref for Sealed { - type Target = T; - - fn deref(&self) -> &Self::Target { - self.inner() - } -} - impl Sealed { /// Instantiate without performing the hash. This should be used carefully. pub const fn new_unchecked(inner: T, seal: B256) -> Self {