chore: add as number helper function (#1139)

This commit is contained in:
Matthias Seitz 2022-04-13 17:23:05 +02:00 committed by GitHub
parent 3d4356f531
commit 0bbd1e3bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -222,6 +222,16 @@ pub enum BlockNumber {
Number(U64),
}
impl BlockNumber {
/// Returns the numeric block number if explicitly set
pub fn as_number(&self) -> Option<U64> {
match *self {
BlockNumber::Number(num) => Some(num),
_ => None,
}
}
}
impl<T: Into<U64>> From<T> for BlockNumber {
fn from(num: T) -> Self {
BlockNumber::Number(num.into())