byteorder icon indicating copy to clipboard operation
byteorder copied to clipboard

Add methods that take/return arrays

Open joshlf opened this issue 4 years ago • 2 comments

The recently-added standard library endian conversion functions like from_be_bytes and to_be_bytes operate on arrays by value rather than slices by reference, which can provide better type safety in some cases.

It would be great if the ByteOrder trait were to add similar methods so that code which still needs to be generic over byte order can benefit from the array approach. Concretely, I would make use of those methods in the zerocopy::byteorder module if they were available.

cc @tamird

joshlf avatar Mar 04 '20 19:03 joshlf

I think this is probably okay... I'm a little skeptical of adding these, because it's a lot of methods. And it's not clear to be how broadly applicable they are. I almost never have an array for example and always need to convert a slice into an array to use the standard library routines.

BurntSushi avatar Jan 06 '21 13:01 BurntSushi