Skip to content

Commit b49dd1d

Browse files
committed
feat: add partialEq u64/u32 for Height
1 parent d8c361e commit b49dd1d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tendermint/src/block/height.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ impl From<u8> for Height {
6666
}
6767
}
6868

69+
impl PartialEq<u64> for Height {
70+
fn eq(&self, other: &u64) -> bool {
71+
self.value() == *other
72+
}
73+
}
74+
75+
impl PartialEq<u32> for Height {
76+
fn eq(&self, other: &u32) -> bool {
77+
self.value() == *other as u64
78+
}
79+
}
80+
6981
impl Height {
7082
/// Get inner integer value. Alternative to `.0` or `.into()`
7183
pub fn value(&self) -> u64 {
@@ -142,4 +154,10 @@ mod tests {
142154
Height::from(2_u32).value()
143155
);
144156
}
157+
158+
#[test]
159+
fn equivalence_check() {
160+
assert!(Height::try_from(10_u64).unwrap() == 10u64);
161+
assert!(Height::try_from(10_u64).unwrap() == 10u32);
162+
}
145163
}

0 commit comments

Comments
 (0)