diff --git a/crates/rpc-types-eth/src/block.rs b/crates/rpc-types-eth/src/block.rs index 1ebf0332bad..c69b1d45084 100644 --- a/crates/rpc-types-eth/src/block.rs +++ b/crates/rpc-types-eth/src/block.rs @@ -190,6 +190,8 @@ impl BlockTransactions { } /// Fallibly cast to a slice of transactions. + /// + /// Returns `None` if the enum variant is not `Full`. pub fn as_transactions(&self) -> Option<&[T]> { match self { Self::Full(txs) => Some(txs), @@ -211,6 +213,15 @@ impl BlockTransactions { self.as_transactions().map(|txs| txs.iter()).unwrap_or_else(|| [].iter()) } + /// Returns an iterator over the transactions (if any). This will be empty if the block is not + /// full. + pub fn into_transactions(self) -> std::vec::IntoIter { + match self { + Self::Full(txs) => txs.into_iter(), + _ => std::vec::IntoIter::default(), + } + } + /// Returns an instance of BlockTransactions with the Uncle special case. #[inline] pub const fn uncle() -> Self {