From aac16ac6061c93fe77633d300cc42166f3d5ca34 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Tue, 25 Jun 2024 02:07:18 -0700 Subject: [PATCH] chore(trie): `TrieOp::as_update` (#9076) --- crates/trie/trie/src/updates.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/trie/trie/src/updates.rs b/crates/trie/trie/src/updates.rs index 39628e6d52..afad628cd7 100644 --- a/crates/trie/trie/src/updates.rs +++ b/crates/trie/trie/src/updates.rs @@ -38,6 +38,15 @@ impl TrieOp { pub const fn is_update(&self) -> bool { matches!(self, Self::Update(..)) } + + /// Returns reference to updated branch node if operation is [`Self::Update`]. + pub const fn as_update(&self) -> Option<&BranchNodeCompact> { + if let Self::Update(node) = &self { + Some(node) + } else { + None + } + } } /// The aggregation of trie updates.