Skip to content

Commit

Permalink
Merge pull request #101 from Daniel-Aaron-Bloom/cfg_if
Browse files Browse the repository at this point in the history
refactor: remove `cfg-if` dependency
  • Loading branch information
str4d authored Mar 9, 2025
2 parents 1791654 + 743fa14 commit e9ee111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
1 change: 0 additions & 1 deletion ff_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ num-integer = "0.1"
proc-macro2 = "1"
quote = "1"
syn = { version = "1", features = ["full"] }
cfg-if = "1"

[badges]
maintenance = { status = "passively-maintained" }
38 changes: 18 additions & 20 deletions ff_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,30 +910,28 @@ fn prime_field_impl(
let from_repr_impl = endianness.from_repr(name, limbs);
let to_repr_impl = endianness.to_repr(quote! {#repr}, &mont_reduce_self_params, limbs);

cfg_if::cfg_if! {
if #[cfg(feature = "bits")] {
let to_le_bits_impl = ReprEndianness::Little.to_repr(
quote! {::ff::derive::bitvec::array::BitArray::new},
&mont_reduce_self_params,
limbs,
);
let prime_field_bits_impl = if cfg!(feature = "bits") {
let to_le_bits_impl = ReprEndianness::Little.to_repr(
quote! {::ff::derive::bitvec::array::BitArray::new},
&mont_reduce_self_params,
limbs,
);

let prime_field_bits_impl = quote! {
impl ::ff::PrimeFieldBits for #name {
type ReprBits = REPR_BITS;
Some(quote! {
impl ::ff::PrimeFieldBits for #name {
type ReprBits = REPR_BITS;

fn to_le_bits(&self) -> ::ff::FieldBits<REPR_BITS> {
#to_le_bits_impl
}
fn to_le_bits(&self) -> ::ff::FieldBits<REPR_BITS> {
#to_le_bits_impl
}

fn char_le_bits() -> ::ff::FieldBits<REPR_BITS> {
::ff::FieldBits::new(MODULUS)
}
fn char_le_bits() -> ::ff::FieldBits<REPR_BITS> {
::ff::FieldBits::new(MODULUS)
}
};
} else {
let prime_field_bits_impl = quote! {};
}
}
})
} else {
None
};

let top_limb_index = limbs - 1;
Expand Down

0 comments on commit e9ee111

Please sign in to comment.