diff --git a/src/hex/convert.rs b/src/hex/convert.rs index 2b32bd7..b2d5350 100644 --- a/src/hex/convert.rs +++ b/src/hex/convert.rs @@ -60,8 +60,8 @@ impl From for Hex { impl Hex { /// Unpack from a [`u64`]. /// [x][`Hex::x`] is read from the most signifigant 32 bits; [y][`Hex::y`] - /// is read from the least signifigant 32 bits. Intended to be used with - /// [`Hex::as_u64`]. + /// is read from the least signifigant 32 bits. The fields are + /// little-endian. Intended to be used with [`Hex::as_u64`]. /// /// # Example /// @@ -74,16 +74,16 @@ impl Hex { #[must_use] #[doc(alias = "unpack")] pub const fn from_u64(value: u64) -> Self { - let x = (value >> 32) as i32; - let y = (value & 0xFFFF_FFFF) as i32; + let x = i32::from_le((value >> 32) as i32); + let y = i32::from_le((value & 0xFFFF_FFFF) as i32); Self::new(x, y) } /// Pack into a [`u64`]. /// [x][`Hex::x`] is placed in the most signifigant 32 bits; [y][`Hex::y`] /// is placed in the least signifigant 32 bits. Can be used as a sort - /// key, or for saving in a binary format. Intended to be used with - /// [`Hex::from_u64`]. + /// key, or for saving in a binary format. The fields are little-endian. + /// Intended to be used with [`Hex::from_u64`]. /// /// # Example /// @@ -97,8 +97,8 @@ impl Hex { #[allow(clippy::cast_sign_loss)] #[doc(alias = "pack")] pub const fn as_u64(self) -> u64 { - let high = (self.x as u32 as u64) << 32; - let low = self.y as u32 as u64; + let high = (self.x.to_le() as u32 as u64) << 32; + let low = self.y.to_le() as u32 as u64; high | low } }