Skip to content

Commit 53b2ac4

Browse files
committed
Fix UInt docs
1 parent fc44ff2 commit 53b2ac4

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/bits/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub mod uint8;
1414
#[macro_use]
1515
pub mod uint;
1616

17-
make_uint!(UInt16, 16, u16, uint16, "16");
18-
make_uint!(UInt32, 32, u32, uint32, "32");
19-
make_uint!(UInt64, 64, u64, uint64, "64");
20-
make_uint!(UInt128, 128, u128, uint128, "128");
17+
make_uint!(UInt16, 16, u16, uint16, "`U16`", "`u16`", "16");
18+
make_uint!(UInt32, 32, u32, uint32, "`U32`", "`u32`", "32");
19+
make_uint!(UInt64, 64, u64, uint64, "`U64`", "`u64`", "64");
20+
make_uint!(UInt128, 128, u128, uint128, "`U128`", "`u128`", "128");
2121

2222
/// Specifies constraints for conversion to a little-endian bit representation
2323
/// of `self`.

src/bits/uint.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
macro_rules! make_uint {
2-
($name:ident, $size:expr, $native:ident, $mod_name:ident, $native_doc_name:expr) => {
3-
#[doc = "This module contains a `UInt"]
2+
($name:ident, $size:expr, $native:ident, $mod_name:ident, $r1cs_doc_name:expr, $native_doc_name:expr, $num_bits_doc:expr) => {
3+
#[doc = "This module contains the "]
4+
#[doc = $r1cs_doc_name]
5+
#[doc = "type, which is the R1CS equivalent of the "]
46
#[doc = $native_doc_name]
5-
#[doc = "`, a R1CS equivalent of the `u"]
6-
#[doc = $native_doc_name]
7-
#[doc = "`type."]
7+
#[doc = " type."]
88
pub mod $mod_name {
99
use ark_ff::{Field, FpParameters, One, PrimeField, Zero};
1010
use core::borrow::Borrow;
@@ -23,13 +23,13 @@ macro_rules! make_uint {
2323
};
2424

2525
#[doc = "This struct represent an unsigned"]
26+
#[doc = $num_bits_doc]
27+
#[doc = " bit integer as a sequence of "]
28+
#[doc = $num_bits_doc]
29+
#[doc = " `Boolean`s. \n"]
30+
#[doc = "This is the R1CS equivalent of the native "]
2631
#[doc = $native_doc_name]
27-
#[doc = "-bit integer as a sequence of "]
28-
#[doc = $native_doc_name]
29-
#[doc = " `Boolean`s\n"]
30-
#[doc = "This is the R1CS equivalent of the native `u"]
31-
#[doc = $native_doc_name]
32-
#[doc = "` unsigned integer type."]
32+
#[doc = " unsigned integer type."]
3333
#[derive(Clone, Debug)]
3434
pub struct $name<F: Field> {
3535
// Least significant bit first
@@ -59,11 +59,11 @@ macro_rules! make_uint {
5959
}
6060

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

@@ -88,9 +88,9 @@ macro_rules! make_uint {
8888
///
8989
/// # Panics
9090
///
91-
/// This method panics if `bits.len() != u
92-
#[doc($native_doc_name)]
93-
#[doc("`.")]
91+
#[doc = "This method panics if `bits.len() != "]
92+
#[doc = $num_bits_doc]
93+
#[doc = "`."]
9494
pub fn from_bits_le(bits: &[Boolean<F>]) -> Self {
9595
assert_eq!(bits.len(), $size);
9696

@@ -337,21 +337,21 @@ macro_rules! make_uint {
337337
false_value: &Self,
338338
) -> Result<Self, SynthesisError> {
339339
let selected_bits = true_value
340-
.bits
341-
.iter()
342-
.zip(&false_value.bits)
340+
.bits
341+
.iter()
342+
.zip(&false_value.bits)
343343
.map(|(t, f)| cond.select(t, f));
344344
let mut bits = [Boolean::FALSE; $size];
345345
for (result, new) in bits.iter_mut().zip(selected_bits) {
346346
*result = new?;
347347
}
348348

349349
let value = cond.value().ok().and_then(|cond| {
350-
if cond {
351-
true_value.value().ok()
352-
} else {
353-
false_value.value().ok()
354-
}
350+
if cond {
351+
true_value.value().ok()
352+
} else {
353+
false_value.value().ok()
354+
}
355355
});
356356
Ok(Self { bits, value })
357357
}

0 commit comments

Comments
 (0)