Skip to content

Releases: Techcable/primint.rs

Only `NonZero`/`NonMax` aliases if those features have been enabled

Choose a tag to compare

@Techcable Techcable released this 05 Sep 05:32
041d974

Fixes

  • Only define NonZero and NonMax aliases if those features have been enabled (qwnmsrvm)
    • Fixes compilation errors present in v0.1.6
  • Only run nonzero/nonmax tests if those features are enabled (pxvwytsn)
  • Fix use of BuildHasher::hash_one breaking doctests before 1.71 (rpnulmvl)

Guarantee NonZero, NonMax have same Ord, Hash as underlying type

Choose a tag to compare

@Techcable Techcable released this 03 Sep 22:08
772196c

Make Hash impl for NonMax satisfy this property.
All other trait implementations already satisfied this.

Changed

  • Officially guarantee that NonMax<T> and NonZero<T> implement Hash the same as T (zoxoyvnx)
  • Similarly guarantee that NonMax<T> and NonZero<T> implement Ord the same as T (lzlwsrtp)
    • This has always been the case for both types.

Fixes

  • The Hash impl for NonMax now behaves the same as the underlying type T. (ppmqkvzx)
    • This property has always been true of NonZero, but has not been true for NonMax

Implement From impls for NonZero, NonMax

Choose a tag to compare

@Techcable Techcable released this 31 Aug 02:40
dc1815a

Added

  • Add type aliases for NonMax and NonZero (i.e. NonZeroU32, NonMaxU32, etc.) (unqpkqks)
  • Add infallible From conversions for NonMax, NonZero (xutqswvn)
    • No failable conversions yet, as that would require defining a TryFromIntError type.
  • Add BITS associated constant to NonMax, NonZero (rslwssvw)
  • Add ONE, ZERO constants to NonMax and ONE constant to NonZero (mkyykwvx)
  • Require PrimitiveInt to implement int format traits (Binary, LowerHex, etc.) (kkmsmlmr)
    • This was always true of the underlying integer types, but not required by the trait.
  • Implement int format traits for NonZero, NonMax (Binary, LowerHex, etc.) (mrlslmyw)
    • Always implemented by delegating to underlying type, just like stdlib and the nonmax crate.

Changes

  • Delegate Debug impl for NonZero, NonMax to underlying type (qnlmtkkx)
    • Makes behavior consistent with stdlib and nonmax crate.
    • Previous behavior for NonZero was to format as newtype tuple struct (0 formats as NonZero(0)]
    • Previous behavior for NonMax was excessively verbose and exposed internal implementation details.
    • I don't consider this breaking since previous behavior was not guaranteed.
      The new behavior is guaranteed unless the stdlib changes it behavior.

Fixes

  • Fix Default impl for NonMax to return zero instead of one.

Make NonZero::new, NonMax::{new, get} a const fn

Choose a tag to compare

@Techcable Techcable released this 26 Aug 05:17
82343b8

Added

  • Implement Display for NonZero, NonMax (svrxxntk)
  • Implement BitOr for NonZero, BitAnd for NonMax (rrlpzwum)

Changed

  • Mark NonZero::new, NonMax::{new, new_unchecked, get} as const fn (vnvwkvzp)

Hide NonZero, NonMax behind on-by-default features.

Choose a tag to compare

@Techcable Techcable released this 25 Aug 16:00
8daea2d

Added

  • Implement Default for NonMax (wmvtkkqk)

Changed

  • Hide NonZero, NonMax behind on-by-default feature flags (nktrlykq)
  • Reduce MSRV from 1.71 back to 1.64 (rupzyqzu)

Fixed

  • Restore compatibility with rust versions before 1.83 by avoiding const_refs_to_cell feature i(ssue #1) (nktrlykq)

Add NonZero and NonMax types, generic over PrimitiveInt

Choose a tag to compare

@Techcable Techcable released this 24 Aug 10:35
bab3396

Added

  • Add wrapping_add and wrapping_sub functions (wznskrrp)
  • Add NonZero struct to mirror core::num::NonZero, but made generic over PrimitiveInt (xooqvysu)
  • Add NonMax struct to mirror the NonZero struct (msuozwwt)
    • Offers alternative to the nonmax crate.
    • Implemented in terms of NonZero type as stdlib doesn't offer it natively.

Changed

  • Bump MSRV to 1.71

Add FromStr bound to PrimitiveInt

Choose a tag to compare

@Techcable Techcable released this 17 Aug 20:53
2dd8fc3

Added

  • Add core::str::FromStr bound to PrimitiveInt (xwvtvksx)

Fixed

  • Remove dead link to nonexistent PrimitiveInteger in crate docs (xxxzxqpn)
    The real trait name is actually PrimitiveInt.

Initial release

Choose a tag to compare

@Techcable Techcable released this 17 Aug 20:26
62316e7

Includes all functionality needed by the intid.rs project.