attaswift / BigInt

Arbitrary-precision arithmetic in pure Swift
MIT License
764 stars 107 forks source link

Consistent "Comparable"? #79

Closed kengruven closed 3 years ago

kengruven commented 3 years ago

This is a minor point which doesn't affect functionality at all, but does slightly affect the API documentation, and it confused me for a little while.

In BigInt/Comparable.swift, it's extension BigUInt: Comparable, but extension BigInt (with no conformances listed). Both extensions define < and ==, and in fact both types are Comparable. It took me a little while to figure out how.

(BigInt/BigUInt -> SignedInteger/UnsignedInteger -> BinaryInteger -> Strideable -> Comparable)

Declaring BigUInt: Comparable is technically redundant. (It's a nice reminder, though, that this type is Comparable.) It would be less confusing if either both types were marked Comparable, or neither were. Thanks!