Fix ToPrimitive for f64 -> f32 conversion.
Fix ToPrimitive for f64 -> f32 conversion.
It should use the destination type and not the source type to check if
the conversion would be to a value that's in range.
NOTE: A finite f64 value that is larger than the f32 value range now produces
None when converted to f32 with ToPrimitive.
Previously, too large f64 values would produce inf f32 values. This `as`
cast has an undefined result and was not specified to always produce for
example `inf`.
The conversion preserves nan/+-inf specifically.
It should use the destination type and not the source type to check if
the conversion would be to a value that's in range.
NOTE: A finite f64 value that is larger than the f32 value range now produces
None when converted to f32 with ToPrimitive.
Previously, too large f64 values would produce inf f32 values. This `as`
cast has an undefined result and was not specified to always produce for
example `inf`.
The conversion preserves nan/+-inf specifically.
For some reason, rustc 1.0.0 can't find `PrimInt` if it's before `cast`,
but later versions are fine with this. That may have been a compiler
bug that was fixed. Switching the order seems to work everywhere.
Add support for Serde 0.7.
Serde 0.7 dropped it's dependency on num, so this patch moves the implementations here. For the sake of a better implementation, this just serializes BigUint as a `Vec<u32>`, `BigInt` as a `(u8, Vec<u32>)`, `Complex<T>` as a `(T, T)`, and `Ratio<T>` as a `(T, T)`.
Serde 0.7 dropped it's dependency on num, so this patch moves
the implementations here. For the sake of a better implementation,
this just serializes BigUint as a `Vec<u32>`, `BigInt` as a
`(u8, Vec<u32>)`, `Complex<T>` as a `(T, T)`, and `Ratio<T>`
as a `(T, T)`.