diff options
author | Andreas Grois <andi@grois.info> | 2022-10-23 20:26:23 +0200 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2022-10-23 20:26:23 +0200 |
commit | 1f57846664b97f0cb630bf5fee13dfbc66f7c77a (patch) | |
tree | ea301ae8471bc8479b1b661508c977039a7c997e /src/passwordmaker/base_conversion/iterative_conversion.rs | |
parent | aa9dc24e9ec72228c28419a9072a4183a461b1f1 (diff) |
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.
Diffstat (limited to 'src/passwordmaker/base_conversion/iterative_conversion.rs')
-rw-r--r-- | src/passwordmaker/base_conversion/iterative_conversion.rs | 6 |
1 files changed, 3 insertions, 3 deletions
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<V,B>{ impl<V,B> IterativeBaseConversion<V,B> where V: for<'a> From<&'a B> + //could be replaced by num::traits::identities::One. - ConstantMaxPowerCache<B>, + PrecomputedMaxPowers<B>, for<'a> &'a V : Mul<&'a B, Output = Option<V>> + //used to get the first current_base_power. Mul<&'a V, Output = Option<V>> { @@ -96,7 +96,7 @@ pub(crate) trait RemAssignWithQuotient{ fn rem_assign_with_quotient(&mut self, divisor : &Self) -> Self; } -pub(crate) trait ConstantMaxPowerCache<B> where Self : Sized{ +pub(crate) trait PrecomputedMaxPowers<B> where Self : Sized{ fn lookup(_base : &B) -> Option<(Self, usize)> { None } } @@ -150,7 +150,7 @@ mod iterative_conversion_tests{ } } - impl ConstantMaxPowerCache<u64> for MyU128{} + impl PrecomputedMaxPowers<u64> for MyU128{} #[test] fn test_simple_u128_to_hex_conversion(){ |