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
//! [`Default`] implementation for [`U256`], returning zero.
use super::U256;
/// Returns the zero value as the default for [`U256`].
///
/// This is consistent with the standard library convention where numeric
/// types default to zero. Equivalent to [`U256::ZERO`].
///
/// # Examples
///
/// ```
/// use cnfy_uint::u256::U256;
///
/// let d: U256 = Default::default();
/// assert_eq!(d, U256::ZERO);
/// ```
impl Default for U256 {
#[inline]
fn default() -> Self {
Self::ZERO
}
}
#[cfg(test)]
mod ai_tests {
use super::*;
/// Default produces the zero value.
#[test]
fn default_is_zero() {
assert_eq!(U256::default(), U256::ZERO);
}
/// Default equals from_be_limbs with all zeros.
#[test]
fn default_matches_explicit_zero() {
assert_eq!(U256::default(), U256::from_be_limbs([0, 0, 0, 0]));
}
}