Skip to content

Commit

Permalink
feat: impl Default for U128 (#6984)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Jan 8, 2025
1 parent c0a4010 commit 3c488f4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion noir_stdlib/src/uint128.nr
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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};

Expand Down Expand Up @@ -565,4 +572,9 @@ mod tests {
),
);
}

#[test]
fn test_default() {
assert_eq(U128::default(), U128::zero());
}
}

0 comments on commit 3c488f4

Please sign in to comment.