Merge rust-bitcoin/rust-bitcoin#2068: Fixes #2011: Customize Debug implementation of `absolute::LockTime`
71a5fe2b54
Customize Debug implementation of absolute::LockTime (Subhradeep Chakraborty) Pull request description: Fixes https://github.com/rust-bitcoin/rust-bitcoin/issues/2011. This PR aims to make the "pretty print" of `absolute::LockTime` prettier by printing `X blocks` and `X seconds` for `Blocks` and `Seconds` respectively instead of the default Enum printing. ACKs for top commit: apoelstra: ACK71a5fe2b54
tcharding: ACK71a5fe2b54
Tree-SHA512: 79baad5ee0ba1aa892cb38588dae6a24977b8e42356208d6cc9adb007d1f8371e61dc82e35bb4dac9961216d68c56907f0db376c5c6fbb5a406728b8f7c3f5ad
This commit is contained in:
commit
eda7e7df0d
|
@ -67,7 +67,7 @@ pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000;
|
|||
/// };
|
||||
/// ```
|
||||
#[allow(clippy::derive_ord_xor_partial_ord)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum LockTime {
|
||||
/// A block height lock time value.
|
||||
///
|
||||
|
@ -294,6 +294,17 @@ impl PartialOrd for LockTime {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for LockTime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use LockTime::*;
|
||||
|
||||
match *self {
|
||||
Blocks(ref h) => write!(f, "{} blocks", h),
|
||||
Seconds(ref t) => write!(f, "{} seconds", t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for LockTime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use LockTime::*;
|
||||
|
|
Loading…
Reference in New Issue