use crate::{integers::uint::*, traits::integers::Add, UnsignedIntegerError};
use snarkvm_fields::{Field, PrimeField};
use snarkvm_r1cs::ConstraintSystem;
macro_rules! add_uint_impl {
($($gadget: ident),*) => ($(
impl<F: Field + PrimeField> Add<F> for $gadget {
type ErrorType = UnsignedIntegerError;
fn add<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, Self::ErrorType> {
<$gadget as UInt>::addmany(cs, &[self.clone(), other.clone()]).map_err(Self::ErrorType::SynthesisError)
}
}
)*)
}
add_uint_impl!(UInt8, UInt16, UInt32, UInt64, UInt128);