Skip to content

Commit

Permalink
impl &mut and Box over setter traits
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Dec 23, 2024
1 parent c55daba commit 0d987e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/context/interface/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ pub trait BlockGetter {
pub trait BlockSetter: BlockGetter {
fn set_block(&mut self, block: <Self as BlockGetter>::Block);
}

impl<T: BlockSetter> BlockSetter for &mut T {
fn set_block(&mut self, block: <Self as BlockGetter>::Block) {
(**self).set_block(block)
}
}

impl<T: BlockSetter> BlockSetter for Box<T> {
fn set_block(&mut self, block: <Self as BlockGetter>::Block) {
(**self).set_block(block)
}
}
12 changes: 12 additions & 0 deletions crates/context/interface/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,15 @@ pub trait TransactionGetter {
pub trait TransactionSetter: TransactionGetter {
fn set_tx(&mut self, tx: <Self as TransactionGetter>::Transaction);
}

impl<T: TransactionSetter> TransactionSetter for &mut T {
fn set_tx(&mut self, block: <Self as TransactionGetter>::Transaction) {
(**self).set_tx(block)
}
}

impl<T: TransactionSetter> TransactionSetter for Box<T> {
fn set_tx(&mut self, block: <Self as TransactionGetter>::Transaction) {
(**self).set_tx(block)
}
}

0 comments on commit 0d987e4

Please sign in to comment.