What it does
Lint uses of from_ne_bytes and to_ne_bytes for code that needs to be endian aware. It may be desirable to force a developer to consider the endian which data should be stored in, especially when sending data across a network or to another machine.
Lint Name
endian_bytes
Category
restriction
Advantage
- Useful for contexts where endianness needs to be considered (such as serialization of data).
Drawbacks
Sometimes it may be desirable to use the host endianness. For example a protocol like Wayland uses host endian.
Example
// 0xFE4415
let ferris = u32::from_ne_bytes([0x00, 0x15, 0x44, 0xFE]);
Could be written as:
// 0xFE4415
let ferris = u32::from_le_bytes([0x00, 0x15, 0x44, 0xFE]);
What it does
Lint uses of
from_ne_bytesandto_ne_bytesfor code that needs to be endian aware. It may be desirable to force a developer to consider the endian which data should be stored in, especially when sending data across a network or to another machine.Lint Name
endian_bytes
Category
restriction
Advantage
Drawbacks
Sometimes it may be desirable to use the host endianness. For example a protocol like Wayland uses host endian.
Example
Could be written as: