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
//! Returns the five `u64` limbs in little-endian order.
use super::U320;
impl U320 {
/// Returns the five `u64` limbs in little-endian order.
///
/// The returned array is `[w0, w1, w2, w3, w4]` where the first element
/// is the least significant limb and the last element is the most
/// significant limb. Since the internal layout is already little-endian,
/// this returns the raw limb array directly.
///
/// # Examples
///
/// ```
/// use cnfy_uint::u320::U320;
///
/// let v = U320::from_be_limbs([1, 2, 3, 4, 5]);
/// assert_eq!(v.to_le_limbs(), [5, 4, 3, 2, 1]);
/// ```
#[inline]
pub const fn to_le_limbs(&self) -> [u64; 5] {
self.0
}
}
#[cfg(test)]
mod ai_tests {
use super::*;
/// to_le_limbs returns the internal LE layout directly.
#[test]
fn le_limbs_reverses() {
let v = U320::from_be_limbs([1, 2, 3, 4, 5]);
assert_eq!(v.to_le_limbs(), [5, 4, 3, 2, 1]);
}
/// Zero in little-endian is still all zeros.
#[test]
fn le_limbs_zero() {
assert_eq!(U320::from_be_limbs([0; 5]).to_le_limbs(), [0; 5]);
}
}