chore: add as number helper function (#1139)
This commit is contained in:
parent
3d4356f531
commit
0bbd1e3bca
|
@ -222,6 +222,16 @@ pub enum BlockNumber {
|
||||||
Number(U64),
|
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 {
|
impl<T: Into<U64>> From<T> for BlockNumber {
|
||||||
fn from(num: T) -> Self {
|
fn from(num: T) -> Self {
|
||||||
BlockNumber::Number(num.into())
|
BlockNumber::Number(num.into())
|
||||||
|
|
Loading…
Reference in New Issue