1

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 1

6
use sp_runtime::traits::SaturatedConversion;


fn f(block_number: BlockNumber) {
    block_number.saturated_into::<u64>();
}
1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.