From 3c488f4b272f460383341c51270b87bfe2b94468 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Wed, 8 Jan 2025 10:13:20 -0300 Subject: [PATCH] feat: impl Default for U128 (#6984) --- noir_stdlib/src/uint128.nr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index c87cae98b3f..ffd6d60b6ca 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -1,6 +1,6 @@ use crate::cmp::{Eq, Ord, Ordering}; use crate::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Not, Rem, Shl, Shr, Sub}; -use super::convert::AsPrimitive; +use super::{convert::AsPrimitive, default::Default}; global pow64: Field = 18446744073709551616; //2^64; global pow63: Field = 9223372036854775808; // 2^63; @@ -331,7 +331,14 @@ impl Shr for U128 { } } +impl Default for U128 { + fn default() -> Self { + U128::zero() + } +} + mod tests { + use crate::default::Default; use crate::ops::Not; use crate::uint128::{pow63, pow64, U128}; @@ -565,4 +572,9 @@ mod tests { ), ); } + + #[test] + fn test_default() { + assert_eq(U128::default(), U128::zero()); + } }