arnaucube
arnaucube/ark-r1cs-stdPublic Self-hosted repository
Fix `UInt` docs
Pratyush Mishra pratyushmishra@berkeley.edu
Wed, 24 Mar 2021 02:10:44 -0700
commit

53b2ac48fa5df10a3bc8f56a73706d0cd22e7d00

parent

fc44ff2de7dbf2f678f0f4abd1db66da9fa0ee8d

2 files changed, 31 insertions(+), 31 deletions(-)

jump to
M src/bits/mod.rs → src/bits/mod.rs

@@ -14,10 +14,10 @@ /// equivalents of `N`-bit unsigned integers.

#[macro_use] pub mod uint; -make_uint!(UInt16, 16, u16, uint16, "16"); -make_uint!(UInt32, 32, u32, uint32, "32"); -make_uint!(UInt64, 64, u64, uint64, "64"); -make_uint!(UInt128, 128, u128, uint128, "128"); +make_uint!(UInt16, 16, u16, uint16, "`U16`", "`u16`", "16"); +make_uint!(UInt32, 32, u32, uint32, "`U32`", "`u32`", "32"); +make_uint!(UInt64, 64, u64, uint64, "`U64`", "`u64`", "64"); +make_uint!(UInt128, 128, u128, uint128, "`U128`", "`u128`", "128"); /// Specifies constraints for conversion to a little-endian bit representation /// of `self`.
M src/bits/uint.rs → src/bits/uint.rs

@@ -1,10 +1,10 @@

macro_rules! make_uint { - ($name:ident, $size:expr, $native:ident, $mod_name:ident, $native_doc_name:expr) => { - #[doc = "This module contains a `UInt"] - #[doc = $native_doc_name] - #[doc = "`, a R1CS equivalent of the `u"] + ($name:ident, $size:expr, $native:ident, $mod_name:ident, $r1cs_doc_name:expr, $native_doc_name:expr, $num_bits_doc:expr) => { + #[doc = "This module contains the "] + #[doc = $r1cs_doc_name] + #[doc = "type, which is the R1CS equivalent of the "] #[doc = $native_doc_name] - #[doc = "`type."] + #[doc = " type."] pub mod $mod_name { use ark_ff::{Field, FpParameters, One, PrimeField, Zero}; use core::borrow::Borrow;

@@ -23,13 +23,13 @@ Assignment, Vec,

}; #[doc = "This struct represent an unsigned"] - #[doc = $native_doc_name] - #[doc = "-bit integer as a sequence of "] - #[doc = $native_doc_name] - #[doc = " `Boolean`s\n"] - #[doc = "This is the R1CS equivalent of the native `u"] + #[doc = $num_bits_doc] + #[doc = " bit integer as a sequence of "] + #[doc = $num_bits_doc] + #[doc = " `Boolean`s. \n"] + #[doc = "This is the R1CS equivalent of the native "] #[doc = $native_doc_name] - #[doc = "` unsigned integer type."] + #[doc = " unsigned integer type."] #[derive(Clone, Debug)] pub struct $name<F: Field> { // Least significant bit first

@@ -59,11 +59,11 @@ }

} impl<F: Field> $name<F> { - #[doc = "Construct a constant `UInt"] - #[doc = $native_doc_name] - #[doc = "` from the native `u"] - #[doc = $native_doc_name] - #[doc = "` type."] + #[doc = "Construct a constant "] + #[doc = $r1cs_doc_name] + #[doc = " from the native "] + #[doc = $native_doc_name] + #[doc = " type."] pub fn constant(value: $native) -> Self { let mut bits = [Boolean::FALSE; $size];

@@ -88,9 +88,9 @@ /// Construct `Self` from a slice of `Boolean`s.

/// /// # Panics /// - /// This method panics if `bits.len() != u - #[doc($native_doc_name)] - #[doc("`.")] + #[doc = "This method panics if `bits.len() != "] + #[doc = $num_bits_doc] + #[doc = "`."] pub fn from_bits_le(bits: &[Boolean<F>]) -> Self { assert_eq!(bits.len(), $size);

@@ -337,9 +337,9 @@ true_value: &Self,

false_value: &Self, ) -> Result<Self, SynthesisError> { let selected_bits = true_value - .bits - .iter() - .zip(&false_value.bits) + .bits + .iter() + .zip(&false_value.bits) .map(|(t, f)| cond.select(t, f)); let mut bits = [Boolean::FALSE; $size]; for (result, new) in bits.iter_mut().zip(selected_bits) {

@@ -347,11 +347,11 @@ *result = new?;

} let value = cond.value().ok().and_then(|cond| { - if cond { - true_value.value().ok() - } else { - false_value.value().ok() - } + if cond { + true_value.value().ok() + } else { + false_value.value().ok() + } }); Ok(Self { bits, value }) }