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
//! Returns the five `u64` limbs in big-endian order.
use super::U320;
impl U320 {
/// Returns the five `u64` limbs in big-endian order.
///
/// The returned array is `[w0, w1, w2, w3, w4]` where `w0` is the most
/// significant limb and `w4` is the least significant limb. The internal
/// little-endian layout is reversed on output.
///
/// # Examples
///
/// ```
/// use cnfy_uint::u320::U320;
///
/// let v = U320::from_be_limbs([1, 2, 3, 4, 5]);
/// assert_eq!(v.to_be_limbs(), [1, 2, 3, 4, 5]);
/// ```
#[inline]
pub const fn to_be_limbs(&self) -> [u64; 5] {
[self.0[4], self.0[3], self.0[2], self.0[1], self.0[0]]
}
}
#[cfg(test)]
mod ai_tests {
use super::*;
/// Round-trip: from_be_limbs then to_be_limbs returns the original array.
#[test]
fn round_trip() {
let arr = [0xA, 0xB, 0xC, 0xD, 0xE];
assert_eq!(U320::from_be_limbs(arr).to_be_limbs(), arr);
}
/// Zero round-trip.
#[test]
fn zero_round_trip() {
assert_eq!(U320::from_be_limbs([0; 5]).to_be_limbs(), [0; 5]);
}
}