diff --git a/corelib/src/zeroable.cairo b/corelib/src/zeroable.cairo index 8685bf09c35..41d7c45c5bd 100644 --- a/corelib/src/zeroable.cairo +++ b/corelib/src/zeroable.cairo @@ -76,6 +76,14 @@ pub(crate) impl Felt252Zeroable = zero_based::ZeroableImpl; /// This type guarantees that the wrapped value is never zero. #[derive(Copy, Drop)] pub extern type NonZero; +impl NonZeroNeg, +TryInto>> of Neg> { + fn neg(a: NonZero) -> NonZero { + // TODO(orizi): Optimize using bounded integers. + let value: T = a.into(); + let negated: T = -value; + negated.try_into().unwrap() + } +} /// Represents the result of checking whether a value is zero. pub(crate) enum IsZeroResult {