I have the following function to detect machine endianness:
fn endianness() -> Endianness {
let x = 0x10u16;
let bytes: [u8; 2] = unsafe { std::mem::transmute(x) };
match bytes {
[1, 0] => Endianness::Big,
[0, 1] => Endianness::Little
}
}
enum Endianness {
Little,
Big
}
Does this have any caveats I should be aware of?