num-traits
num-traits copied to clipboard
convert between integer and byte array
After Rust 1.32, the function to_<endian>_bytes
and from_<endian>_bytes
has stabilizations.
Tests seem crashed at src/int.rs - int::PrimInt::unsigned_shr (line 173)
---- src/int.rs - int::PrimInt::unsigned_shr (line 173) stdout ----
error: literal out of range for i64
--> src/int.rs:176:9
|
6 | let n = 0xFEDCBA9876543210i64;
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0xFEDCBA9876543210u64`
|
= note: #[deny(overflowing_literals)] on by default
= note: the literal `0xFEDCBA9876543210i64` (decimal `18364758544493064720`) does not fit into an `i64` and will become `-81985529216486896i64`
thread 'src/int.rs - int::PrimInt::unsigned_shr (line 173)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
The PR seems to have gone fallow, but if you come back to it, it'd be great to extend this to the float types as they also got these methods in 1.40.
Hi @erikbrinkman and @cuviper
The PR has be updated
- The trait has been renamed to
ToFromBytes
- Use
autocfg
to check the expression - Implements
ToFromBytes
for integer and float
Sorry, I pushed to this branch on accident, but the revived development is in #224.