Skip to content

Commit

Permalink
absolute: make is_* methods uniform with the ones from relative
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Mar 21, 2024
1 parent 878b865 commit 04715e3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bitcoin/src/blockdata/locktime/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//!

use core::cmp::Ordering;
use core::{fmt, mem};
use core::fmt;

use io::{BufRead, Write};
#[cfg(all(test, mutate))]
Expand Down Expand Up @@ -170,18 +170,17 @@ impl LockTime {

/// Returns true if both lock times use the same unit i.e., both height based or both time based.
#[inline]
pub fn is_same_unit(&self, other: LockTime) -> bool {
mem::discriminant(self) == mem::discriminant(&other)
pub const fn is_same_unit(&self, other: LockTime) -> bool {
matches!(
(self, other),
(LockTime::Blocks(_), LockTime::Blocks(_))
| (LockTime::Seconds(_), LockTime::Seconds(_))
)
}

/// Returns true if this lock time value is a block height.
#[inline]
pub const fn is_block_height(&self) -> bool {
match *self {
LockTime::Blocks(_) => true,
LockTime::Seconds(_) => false,
}
}
pub const fn is_block_height(&self) -> bool { matches!(*self, LockTime::Blocks(_)) }

/// Returns true if this lock time value is a block time (UNIX timestamp).
#[inline]
Expand Down

0 comments on commit 04715e3

Please sign in to comment.