From 344264e03d7635b9bd2688390100d3b9f623c58a Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Fri, 4 Nov 2022 00:12:14 +0100 Subject: Some clippy lints. Some were fixed, some were ignored because they seem to make a (negative) performance impact. --- src/passwordmaker/base_conversion/iterative_conversion.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/passwordmaker/base_conversion/iterative_conversion.rs') diff --git a/src/passwordmaker/base_conversion/iterative_conversion.rs b/src/passwordmaker/base_conversion/iterative_conversion.rs index 710903e..c8c121c 100644 --- a/src/passwordmaker/base_conversion/iterative_conversion.rs +++ b/src/passwordmaker/base_conversion/iterative_conversion.rs @@ -20,6 +20,7 @@ pub(crate) struct IterativeBaseConversion{ switch_to_multiplication : bool, //count the number of divisions. After 1, current_value is smaller than max_base_power. After 2, it's safe to mutliply current_value by base. } +#[allow(clippy::trait_duplication_in_bounds)] //That's obviously a false-positive in clippy... impl IterativeBaseConversion where V: for<'a> From<&'a B> + //could be replaced by num::traits::identities::One. PrecomputedMaxPowers, @@ -37,6 +38,7 @@ impl IterativeBaseConversion } } + #[allow(clippy::map_unwrap_or)] //current code seems to be measurably faster. fn find_highest_fitting_power(base : &B) -> PowerAndExponent { V::lookup(base).map(|(power,count)| PowerAndExponent{ power, exponent: count }) .unwrap_or_else(|| Self::find_highest_fitting_power_non_cached(base)) @@ -66,6 +68,7 @@ impl std::iter::Iterator for IterativeBaseConversion { type Item = B; + #[allow(clippy::assign_op_pattern)] //measurable performance difference. No, this doesn't make sense. fn next(&mut self) -> Option { if self.remaining_digits == 0 { None @@ -75,7 +78,7 @@ impl std::iter::Iterator for IterativeBaseConversion if self.switch_to_multiplication { //mul_assign is in principle dangerous. //Since we do two rem_assign_with_quotient calls first, we can be sure that the result is always smaller than base^max_power though. - self.current_value *= &self.base + self.current_value *= &self.base; } else { self.current_base_power /= &self.base; self.switch_to_multiplication = true; -- cgit v1.2.3