cnfy-uint 0.2.3

Zero-dependency 256-bit unsigned integer arithmetic for cryptographic applications
Documentation
//! Conversion from `[u64; 6]` into [`U384`] via the [`From`] trait.
use super::U384;

/// Creates a [`U384`] from a six-element `u64` array in big-endian order.
///
/// This is equivalent to [`U384::from_be_limbs`] but available through
/// the standard [`From`] trait for ergonomic conversions.
///
/// # Examples
///
/// ```
/// use cnfy_uint::u384::U384;
///
/// let v: U384 = [0, 0, 0, 0, 0, 42u64].into();
/// assert_eq!(v, U384::from_be_limbs([0, 0, 0, 0, 0, 42]));
/// ```
impl From<[u64; 6]> for U384 {
    #[inline]
    fn from(value: [u64; 6]) -> Self {
        Self::from_be_limbs(value)
    }
}

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

    /// Round-trip from array through U384 back to limbs.
    #[test]
    fn round_trip() {
        let arr = [1u64, 2, 3, 4, 5, 6];
        let v = U384::from(arr);
        assert_eq!(v.to_be_limbs(), arr);
    }

    /// Zero array produces zero value.
    #[test]
    fn zero() {
        assert_eq!(U384::from([0u64; 6]), U384::from_be_limbs([0; 6]));
    }

    /// Matches from_be_limbs behavior.
    #[test]
    fn matches_from_be_limbs() {
        let arr = [0xA, 0xB, 0xC, 0xD, 0xE, 0xF];
        assert_eq!(U384::from(arr), U384::from_be_limbs(arr));
    }
}