diff --git a/README.md b/README.md index 599e4b8..60fc410 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This crate uses Rust's const generics to allow creation of integers of arbitrary - **Zero dependencies by default**: `bnum` does not depend on any other crates by default. Support for crates such as [`rand`](https://docs.rs/rand/latest/rand/) and [`serde`](https://docs.rs/serde/latest/serde/) can be enabled with crate [features](#features). - **`no-std` compatible**: `bnum` can be used in `no_std` environments, provided that the [`arbitrary`](#fuzzing) and [`quickcheck`](#quickcheck) features are not enabled. -- **Compile-time integer parsing**: the `from_str_radix` and `parse_str_radix` methods on `bnum` integers are `const`, which allows parsing of integers from string slices at compile time. Note that this is more powerful than compile-time parsing of integer literals. This is because it allows parsing of strings in all radices from `2` to `36` inclusive instead of just `2`, `8`, `10` and `16`. Additionally, the string to be parsed does not have to be a literal: it could, for example, be obtained via [`include_str!`](https://doc.rust-lang.org/core/macro.include_str.html), or [`env!`](https://doc.rust-lang.org/core/macro.env.html)`. +- **Compile-time integer parsing**: the `from_str_radix` and `parse_str_radix` methods on `bnum` integers are `const`, which allows parsing of integers from string slices at compile time. Note that this is more powerful than compile-time parsing of integer literals. This is because it allows parsing of strings in all radices from `2` to `36` inclusive instead of just `2`, `8`, `10` and `16`. Additionally, the string to be parsed does not have to be a literal: it could, for example, be obtained via [`include_str!`](https://doc.rust-lang.org/core/macro.include_str.html), or [`env!`](https://doc.rust-lang.org/core/macro.env.html). - **`const` evaluation**: nearly all methods defined on `bnum` integers are `const`, which allows complex compile-time calculations. ## Installation diff --git a/src/buint/as_float.rs b/src/buint/as_float.rs index d81a4da..3261564 100644 --- a/src/buint/as_float.rs +++ b/src/buint/as_float.rs @@ -144,7 +144,7 @@ pub trait Mantissa { fn add(self, rhs: Self) -> Self; fn sub(self, rhs: Self) -> Self; fn leading_zeros(self) -> ExpType; - fn bitand(self, rhs: Self) -> Self; + // fn bitand(self, rhs: Self) -> Self; fn gt(&self, rhs: &Self) -> bool; } @@ -188,10 +188,10 @@ macro_rules! impl_mantissa_for_uint { Self::leading_zeros(self) as ExpType } - #[inline] - fn bitand(self, rhs: Self) -> Self { - self & rhs - } + // #[inline] + // fn bitand(self, rhs: Self) -> Self { + // self & rhs + // } #[inline] fn gt(&self, rhs: &Self) -> bool { diff --git a/src/buint/endian.rs b/src/buint/endian.rs index e484b7f..532f847 100644 --- a/src/buint/endian.rs +++ b/src/buint/endian.rs @@ -233,7 +233,7 @@ macro_rules! endian { #[inline] pub const fn from_be_bytes(bytes: [u8; N * digit::$Digit::BYTES as usize]) -> Self { let mut out = Self::ZERO; - let arr_ptr = bytes.as_ptr(); + // let arr_ptr = bytes.as_ptr(); let mut i = 0; while i < N { let mut digit_bytes = [0u8; digit::$Digit::BYTES as usize]; @@ -256,7 +256,7 @@ macro_rules! endian { #[inline] pub const fn from_le_bytes(bytes: [u8; N * digit::$Digit::BYTES as usize]) -> Self { let mut out = Self::ZERO; - let arr_ptr = bytes.as_ptr(); + // let arr_ptr = bytes.as_ptr(); let mut i = 0; while i < N { let mut digit_bytes = [0u8; digit::$Digit::BYTES as usize]; diff --git a/src/cast.rs b/src/cast.rs index f4ace6c..74b9a46 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -8,6 +8,7 @@ pub trait CastFrom { } // #[cfg_attr(feature = "nightly", const_trait)] +#[cfg(test)] pub(crate) trait CastTo { fn cast_to(self) -> U; } @@ -55,6 +56,7 @@ assert_eq!(b, f.as_()); macro_rules! as_trait { () => { // impl const CastTo for T + #[cfg(test)] impl CastTo for T where // U: ~const CastFrom, @@ -93,6 +95,7 @@ macro_rules! as_trait { #[cfg(not(feature = "nightly"))] macro_rules! as_trait { () => { + #[cfg(test)] impl CastTo for T where U: CastFrom,