It would be nice if Signed and Unsigned had a way to convert between each other, presumably via:
Signed::abs_unsigned, which would losslessly convert the signed version to an unsigned version of the same size (wrapping_abs + as for primitives, and just extracting the inner BigUint for BigInt)
Unsigned::try_signed, which would allow casting to the signed version if available.
Signed::Unsigned and Unsigned::Signed, two associated types that would do the job.
This would be a breaking change but a useful one. For example, a Pow implementation for Ratio could leverage these methods so that the signed and unsigned versions relied on each others' implementations, instead of duplicating code.
I've decided to limit the clutter of breaking change issues, so they will now be tracked collectively in #47. I'm closing this issue for now as postponed but we can still discuss its merits here as needed.
It would be nice if
Signed
andUnsigned
had a way to convert between each other, presumably via:Signed::abs_unsigned
, which would losslessly convert the signed version to an unsigned version of the same size (wrapping_abs
+as
for primitives, and just extracting the innerBigUint
forBigInt
)Unsigned::try_signed
, which would allow casting to the signed version if available.Signed::Unsigned
andUnsigned::Signed
, two associated types that would do the job.This would be a breaking change but a useful one. For example, a
Pow
implementation forRatio
could leverage these methods so that the signed and unsigned versions relied on each others' implementations, instead of duplicating code.