Skip to content

Commit e291922

Browse files
committed
Test aliases
1 parent b58a33f commit e291922

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/aliases.rs

+26
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,29 @@ alias! {
6262
}
6363

6464
// TODO: I0, I1, I8, ... I4096
65+
66+
#[cfg(test)]
67+
pub mod tests {
68+
use super::*;
69+
70+
#[test]
71+
fn instantiate_consts() {
72+
let _ = (U0::ZERO, U0::MAX, B0::ZERO);
73+
let _ = (U1::ZERO, U1::MAX, B1::ZERO);
74+
let _ = (U8::ZERO, U8::MAX, B8::ZERO);
75+
let _ = (U16::ZERO, U16::MAX, B16::ZERO);
76+
let _ = (U32::ZERO, U32::MAX, B32::ZERO);
77+
let _ = (U64::ZERO, U64::MAX, B64::ZERO);
78+
let _ = (U128::ZERO, U128::MAX, B128::ZERO);
79+
let _ = (U160::ZERO, U160::MAX, B160::ZERO);
80+
let _ = (U192::ZERO, U192::MAX, B192::ZERO);
81+
let _ = (U256::ZERO, U256::MAX, B256::ZERO);
82+
let _ = (U320::ZERO, U320::MAX, B320::ZERO);
83+
let _ = (U384::ZERO, U384::MAX, B384::ZERO);
84+
let _ = (U448::ZERO, U448::MAX, B448::ZERO);
85+
let _ = (U512::ZERO, U512::MAX, B512::ZERO);
86+
let _ = (U1024::ZERO, U1024::MAX, B1024::ZERO);
87+
let _ = (U2048::ZERO, U2048::MAX, B2048::ZERO);
88+
let _ = (U4096::ZERO, U4096::MAX, B4096::ZERO);
89+
}
90+
}

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
155155

156156
/// The value zero. This is the only value that exists in all [`Uint`]
157157
/// types.
158-
pub const ZERO: Self = Self { limbs: [0; LIMBS] };
158+
pub const ZERO: Self = Self::from_limbs([0; LIMBS]);
159159

160160
/// The largest value that can be represented by this integer type,
161161
/// $2^{\mathtt{BITS}} − 1$.
@@ -164,7 +164,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
164164
if BITS > 0 {
165165
limbs[LIMBS - 1] &= Self::MASK;
166166
}
167-
Self { limbs }
167+
Self::from_limbs(limbs)
168168
};
169169

170170
/// View the array of limbs.

0 commit comments

Comments
 (0)