From 1f57846664b97f0cb630bf5fee13dfbc66f7c77a Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sun, 23 Oct 2022 20:26:23 +0200 Subject: Add precomputed constants for common cases. There are now 2 features that control the amount of precomputed constants. They can either be 0, 12, or 256. Most users will likely want to go with the 12, so this is the default feature. --- src/passwordmaker/base_conversion/iterative_conversion.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (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 e88f379..438ef20 100644 --- a/src/passwordmaker/base_conversion/iterative_conversion.rs +++ b/src/passwordmaker/base_conversion/iterative_conversion.rs @@ -21,7 +21,7 @@ pub(crate) struct IterativeBaseConversion{ impl IterativeBaseConversion where V: for<'a> From<&'a B> + //could be replaced by num::traits::identities::One. - ConstantMaxPowerCache, + PrecomputedMaxPowers, for<'a> &'a V : Mul<&'a B, Output = Option> + //used to get the first current_base_power. Mul<&'a V, Output = Option> { @@ -96,7 +96,7 @@ pub(crate) trait RemAssignWithQuotient{ fn rem_assign_with_quotient(&mut self, divisor : &Self) -> Self; } -pub(crate) trait ConstantMaxPowerCache where Self : Sized{ +pub(crate) trait PrecomputedMaxPowers where Self : Sized{ fn lookup(_base : &B) -> Option<(Self, usize)> { None } } @@ -150,7 +150,7 @@ mod iterative_conversion_tests{ } } - impl ConstantMaxPowerCache for MyU128{} + impl PrecomputedMaxPowers for MyU128{} #[test] fn test_simple_u128_to_hex_conversion(){ -- cgit v1.2.3