Skip to content

Commit 300efbb

Browse files
committed
Remove a few casts
In an effort to be more readable use `usize::from` instead of a cast. There are a few casts left but this all the ones that can use `From`. Refactor only, no logic changes. Close rust-bitcoin#181
1 parent b9eb76f commit 300efbb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/primitives/gf32.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ impl super::Field for Fe32 {
270270
if self.0 == 0 || other.0 == 0 {
271271
Fe32(0)
272272
} else {
273-
let log1 = LOG[self.0 as usize];
274-
let log2 = LOG[other.0 as usize];
273+
let log1 = LOG[usize::from(self.0)];
274+
let log2 = LOG[usize::from(other.0)];
275275
let mult_order = Self::MULTIPLICATIVE_ORDER as isize;
276276
Fe32(LOG_INV[((log1 + log2) % mult_order) as usize])
277277
}
@@ -282,8 +282,8 @@ impl super::Field for Fe32 {
282282
} else if other.0 == 0 {
283283
panic!("Attempt to divide {} by 0 in GF32", self);
284284
} else {
285-
let log1 = LOG[self.0 as usize];
286-
let log2 = LOG[other.0 as usize];
285+
let log1 = LOG[usize::from(self.0)];
286+
let log2 = LOG[usize::from(other.0)];
287287
let mult_order = Self::MULTIPLICATIVE_ORDER as isize;
288288
Fe32(LOG_INV[((mult_order + log1 - log2) % mult_order) as usize])
289289
}

0 commit comments

Comments
 (0)