Cast after calling min

In an effort to reduce the cognitive load of reading code we are
removing casts unless they are useful or obvious.

Move the cast onto the call to `min` and comment it for good measure.
This allows us to call infallible `from` for conversion when needed.

Refactor only, no logic changes.
This commit is contained in:
Tobin C. Harding 2024-08-05 07:43:58 +10:00
parent 342fe18ad0
commit ea9f6e8f97
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 3 additions and 3 deletions

View File

@ -435,9 +435,9 @@ impl GcsFilter {
let mut wrote = 0; let mut wrote = 0;
let mut q = n >> self.p; let mut q = n >> self.p;
while q > 0 { while q > 0 {
let nbits = cmp::min(q, 64); let nbits = cmp::min(q, 64) as u8; // cast ok, 64 fits into a `u8`
wrote += writer.write(!0u64, nbits as u8)?; wrote += writer.write(!0u64, nbits)?;
q -= nbits; q -= u64::from(nbits);
} }
wrote += writer.write(0, 1)?; wrote += writer.write(0, 1)?;
wrote += writer.write(n, self.p)?; wrote += writer.write(n, self.p)?;