cnfy-uint 0.2.3

Zero-dependency 256-bit unsigned integer arithmetic for cryptographic applications
Documentation
//! Returns the eight `u64` limbs in little-endian order.
use super::U512;

impl U512 {
    /// Returns the eight `u64` limbs in little-endian order.
    ///
    /// The returned array is `[w7, w6, w5, w4, w3, w2, w1, w0]` where the
    /// first element is the least significant limb and the last element is
    /// the most significant limb.
    ///
    /// # Examples
    ///
    /// ```
    /// use cnfy_uint::u512::U512;
    ///
    /// let v = U512::from_be_limbs([1, 2, 3, 4, 5, 6, 7, 8]);
    /// assert_eq!(v.to_le_limbs(), [8, 7, 6, 5, 4, 3, 2, 1]);
    /// ```
    #[inline]
    pub const fn to_le_limbs(&self) -> [u64; 8] {
        self.0
    }
}

#[cfg(test)]
mod ai_tests {
    use super::*;

    /// to_le_limbs reverses the big-endian order.
    #[test]
    fn le_limbs_reverses() {
        let v = U512::from_be_limbs([1, 2, 3, 4, 5, 6, 7, 8]);
        assert_eq!(v.to_le_limbs(), [8, 7, 6, 5, 4, 3, 2, 1]);
    }

    /// Zero in little-endian is still all zeros.
    #[test]
    fn le_limbs_zero() {
        assert_eq!(U512::from_be_limbs([0; 8]).to_le_limbs(), [0; 8]);
    }
}