diff --git a/src/lib.rs b/src/lib.rs index a9afd5e..213a5c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,23 +14,18 @@ use core::{ ops::{Add, AddAssign, BitAnd, BitOr, Shl, Shr}, }; -/// Base set of values and +/// Base set of values and operations needed for our implementation pub trait FletcherAccumulator: Sized + Copy + Default + From - + Add - + From<::Output> + + Add + AddAssign - + BitAnd - + From<::Output> - + BitOr - + From<::Output> - + Shl - + From<>::Output> - + Shr - + From<>::Output> + + BitAnd + + BitOr + + Shl + + Shr + PartialEq { type InputType: Copy; @@ -141,7 +136,7 @@ where /// This function assumes that the accumulators have already /// been fully reduced. fn combine(lower: T, upper: T) -> T { - (lower | (upper << T::SHIFT_AMOUNT).into()).into() + lower | (upper << T::SHIFT_AMOUNT) } /// Reduces the accumulator value @@ -149,9 +144,9 @@ where /// This function needs to reduce the accumulator value in a manner /// that rounds the value according to one's compliment math. fn reduce(value: T) -> T { - let lhs: T = (value & T::BIT_MASK).into(); - let rhs: T = (value >> T::SHIFT_AMOUNT).into(); - let result: T = (lhs + rhs).into(); + let lhs: T = value & T::BIT_MASK; + let rhs: T = value >> T::SHIFT_AMOUNT; + let result: T = lhs + rhs; if result == T::BIT_MASK { T::default() } else {