Closed
Description
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 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 for Ratio
could leverage these methods so that the signed and unsigned versions relied on each others' implementations, instead of duplicating code.