Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## v0.40.4

- `[tendermint]` Implement PartialEq<u64> for `Height`. ([\#1507](https://github.com/cometbft/tendermint-rs/issues/1507))

*May 5th, 2025*

### BUG FIXES
Expand Down
18 changes: 18 additions & 0 deletions tendermint/src/block/height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ impl From<u8> for Height {
}
}

impl PartialEq<u64> for Height {
fn eq(&self, other: &u64) -> bool {
self.value() == *other
}
}

impl PartialEq<u32> for Height {
fn eq(&self, other: &u32) -> bool {
self.value() == *other as u64
}
}

impl Height {
/// Get inner integer value. Alternative to `.0` or `.into()`
pub fn value(&self) -> u64 {
Expand Down Expand Up @@ -142,4 +154,10 @@ mod tests {
Height::from(2_u32).value()
);
}

#[test]
fn equivalence_check() {
assert!(Height::try_from(10_u64).unwrap() == 10u64);
assert!(Height::try_from(10_u64).unwrap() == 10u32);
}
}