Skip to content

Alpha Release v0.5.0

Pre-release
Pre-release

Choose a tag to compare

@jngls jngls released this 10 Mar 16:39
· 29 commits to main since this release
7b9a99f
  • DilatedInt now takes a generic DilationMethod adapter <A> instead of <T, D>
  • The DilationMethod describes the type of dilation, including the inner and outer types involved, wrapper methods to forward to the appropriate dilation functions, and some useful constants
  • At the moment, there are two types of DilationMethod impls:
    • Expand<T, D> is a method which describes the v0.4.0 dilation implementation - the inner type adapts to the combination of T and D, choosing the smallest type that would contain all bits of the outer type D-dilated. There are naturally a limited number of T and D combinations available as the the largest integer type supported is u128
    • Fixed<T, D> is a method adapter which describes the pre-0.4.0 dilation implementation - the inner type is the same as the outer type and a limited subset of bits in the outer type can be dilated. This is useful when you want absolute control over the inner type used and want to fit as many dilated bits into the inner type as possible.
  • In both cases, the number of possible dilatable bits is given by DilationMethod::UNDILATED_BITS and the maximum dilated value is given by DilationMethod::DILATED_MAX (formerly the DilatedMask trait which was discarded in favour of constants closely mimicking the rust standard T::BITS and T::MAX).
  • As a result of this change, we are no longer relying on multiple macros to produce implementations for different types - almost everything except the DilationMethod impls use regular trait impls. The code is easier to read as a result.
  • We no longer use From. The use cases of From do not accurately convey what is happening when converting to and from dilated integers. Users should now use the explicit regular_uint.dilate_expand::<D>() or regular_uint.dilate_fixed::<D>() and dilated_int.undilate() methods. Note that regular_uint.dilate_expand::<D>() returns a DilatedInt<Expand<T, D>>, regular_uint.dilate_fixed() returns a DilatedInt<Fixed<T, D>> and dilated_int.undilate() returns a the original type of the uint T.

Migration Notes

  • DilatedInt now takes a DilationMethod adapter <A> in place of <T, D>. This is to allow for different formats of dilation. The 0.4.0 behaviour may be implemented using DilatedInt<Expand<T, D>>. The old pre-0.4.0 behaviour may be implemented using DilatedInt<Fixed<T, D>>.
  • You now convert between ints and DilatedInt using the explicit regular_uint.dilate_expand::<D>() or regular_uint.dilate_fixed::<D>() and dilated_int.undilate() methods. This is because use cases of the From impls are extremely hard to read at a glance. Explicit methods better show what is happening.

Full Changelog: v0.4.0...v0.5.0