byteorder icon indicating copy to clipboard operation
byteorder copied to clipboard

write_int never panics on out of range input

Open fintelia opened this issue 10 months ago • 0 comments

The documentation for ByteOrder::write_int says:

If n is not representable in nbytes, or if nbytes is > 8, then this method panics.

However, passing inputs that fail the first condition doesn't actually cause a panic:

BigEndian::write_int(&mut [0; 8], 99999999, 1); // Doesn't panic
BigEndian::write_int(&mut [0; 8], -99999999, 1); // Also doesn't panic

fintelia avatar Apr 02 '24 04:04 fintelia