1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! 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));
}
}