From 342fe18ad0604e3acb1e73c7ae628315a7ceb674 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 5 Aug 2024 07:29:36 +1000 Subject: [PATCH] Use From in map_to_range In an effort to remove unnecessary casts use `u128::from` to convert from `u64`s. Leave the cast to `u64` in there because it is right after a shift right and is brain-dead obvious. --- bitcoin/src/bip158.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs index 5b9084f7c..d737f22fa 100644 --- a/bitcoin/src/bip158.rs +++ b/bitcoin/src/bip158.rs @@ -362,7 +362,7 @@ impl GcsFilterReader { } /// Fast reduction of hash to [0, nm) range. -fn map_to_range(hash: u64, nm: u64) -> u64 { ((hash as u128 * nm as u128) >> 64) as u64 } +fn map_to_range(hash: u64, nm: u64) -> u64 { ((u128::from(hash) * u128::from(nm)) >> 64) as u64 } /// Golomb-Rice encoded filter writer. pub struct GcsFilterWriter<'a, W> {