For example, if a have a variable of type <T as frame_system::Config>::BlockNumber
how could I convert it into a u64
, simply putting u64::from
doesn't work.
1 Answer
use sp_runtime::traits::SaturatedConversion;
fn f(block_number: BlockNumber) {
block_number.saturated_into::<u64>();
}
-
Depending on what is the intended behaviour when the block number doesn't fit into 64 bits, using CheckedConversion might be an option as well. Sep 27, 2022 at 9:07