Skip to content

Commit 0c4dc2d

Browse files
refactor(core): add Display as a supertrait of BlockHashExt and TxidExt
Adds Display as a supertrait of BlockHashExt and TxidExt to reflect that all hash and txid types are displayable, improving ergonomics and readability.
1 parent fee5a6a commit 0c4dc2d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/core/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ use super::transaction::{TransactionRef, TxOutRef};
146146
/// let hash = BlockHash::from([1u8; 32]);
147147
/// display_hash(&hash);
148148
/// ```
149-
pub trait BlockHashExt: AsPtr<btck_BlockHash> {
149+
pub trait BlockHashExt: AsPtr<btck_BlockHash> + std::fmt::Display {
150150
/// Serializes the block hash to raw bytes.
151151
///
152152
/// Returns the 32-byte representation of the block hash in internal byte order.

src/core/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<'a> Clone for TxOutPointRef<'a> {
651651
impl<'a> Copy for TxOutPointRef<'a> {}
652652

653653
/// Common operations for transaction IDs, implemented by both owned and borrowed types.
654-
pub trait TxidExt: AsPtr<btck_Txid> {
654+
pub trait TxidExt: AsPtr<btck_Txid> + Display {
655655
/// Serializes the txid to raw bytes.
656656
fn to_bytes(&self) -> [u8; 32] {
657657
let mut bytes = [0u8; 32];

0 commit comments

Comments
 (0)