diff --git a/Cargo.toml b/Cargo.toml index dcd228d3..8a49bb8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fraction" -version = "0.15.3" +version = "0.16.0" authors = ["dnsl48 "] description = "Lossless fractions and decimals; drop-in float replacement" @@ -27,7 +27,7 @@ opt-level = 3 [dependencies] -num = { version = "0.4.2", default-features = false } +num = { version = "0.4.3", default-features = false } byteorder = { version = "1", optional = true } bytes = { version = "1", optional = true } @@ -56,8 +56,8 @@ with-serde-support = ["serde", "serde_derive", "num/serde"] with-unicode = [] [dev-dependencies] -criterion = "0.4" -rand = "0.8.5" +criterion = "0.5" +rand = "0.8" [[bench]] name = "bench_fraction" diff --git a/src/decimal/postgres_support.rs b/src/decimal/postgres_support.rs index 76317a39..d39de616 100644 --- a/src/decimal/postgres_support.rs +++ b/src/decimal/postgres_support.rs @@ -35,7 +35,7 @@ where r#" your decimal type supports up to "#, P::max_value(), r#"you may increase the precision type size up to "usize", which is "#, - usize::max_value(), + usize::MAX, r#"PostgreSQL supports precision up to "#, PG_MAX_PRECISION ) diff --git a/src/dynaint.rs b/src/dynaint.rs index 357b01fc..56023cef 100644 --- a/src/dynaint.rs +++ b/src/dynaint.rs @@ -113,7 +113,7 @@ where /// Unpacks the value /// - /// Utilises [Result::Ok] for S(small) numbers and [Result::Err] for __H(huge) ones + /// Utilises [Ok] for S(small) numbers and [Err] for __H(huge) ones /// /// # Examples /// ``` @@ -887,7 +887,6 @@ where dyna_impl!(impl_fn_refmath; gcd); dyna_impl!(impl_fn_refmath; lcm); - dyna_impl!(impl_fn_refmath_bool; divides); dyna_impl!(impl_fn_refmath_bool; is_multiple_of); dyna_impl!(impl_fn_isref; is_even); @@ -916,7 +915,7 @@ where T: Copy + GenericInteger + Into + TryToConvertFrom + From + ToBigUint, G: Clone + GenericInteger + ToBigUint, { - fn to_biguint(&self) -> Option { + fn to_biguint(&self) -> Option { match self { DynaInt::S(s) => s.to_biguint(), DynaInt::__H(h) => h.to_biguint(), @@ -943,7 +942,7 @@ mod tests { #[test] fn growth() { - let m8 = u8::max_value(); + let m8 = u8::MAX; let mut val = D::from(m8); @@ -1242,8 +1241,8 @@ mod tests { D::from(256u16).checked_add(&D::from(256u16)) ); - assert_eq!(None, D::from(u16::max_value()).checked_add(&D::one())); - assert_eq!(None, D::one().checked_add(&D::from(u16::max_value()))); + assert_eq!(None, D::from(u16::MAX).checked_add(&D::one())); + assert_eq!(None, D::one().checked_add(&D::from(u16::MAX))); } #[test] @@ -1282,10 +1281,10 @@ mod tests { assert_eq!(D::from(128u8), D::from(256u16).div_floor(&D::from(2u8))); assert_eq!(D::one(), D::from(257u16).div_floor(&D::from(256u16))); - assert!(D::one().divides(&D::one())); - assert!(!D::one().divides(&D::from(257u16))); - assert!(D::from(257u16).divides(&D::one())); - assert!(!D::from(257u16).divides(&D::from(256u16))); + assert!(D::one().is_multiple_of(&D::one())); + assert!(!D::one().is_multiple_of(&D::from(257u16))); + assert!(D::from(257u16).is_multiple_of(&D::one())); + assert!(!D::from(257u16).is_multiple_of(&D::from(256u16))); assert!(D::one().is_odd()); assert!(D::from(256u16).is_even()); diff --git a/src/fraction/approx.rs b/src/fraction/approx.rs index 86bfee15..d5cd240a 100644 --- a/src/fraction/approx.rs +++ b/src/fraction/approx.rs @@ -74,11 +74,11 @@ impl Accuracy { /// printed as binary". /// /// Prefer using [`Accuracy::decimal_places`] when `base == 10`. - pub fn base_places(base: B, n: N) -> Self + pub fn base_places(base: B, n: N) -> Self where // Assuming `n` is anything other than really small, `base^n` will likely be pretty big, so // we calculate the multiplier using `BigUint`. - B: Into, + B: Into + GenericInteger, // We need to be able to raise `BigUint(base)` to the power of `n`... BigUint: Pow, diff --git a/src/fraction/unicode_str_io.rs b/src/fraction/unicode_str_io.rs index f8506bcb..62dc6c9e 100644 --- a/src/fraction/unicode_str_io.rs +++ b/src/fraction/unicode_str_io.rs @@ -233,10 +233,10 @@ impl> GenericFraction { pub fn from_unicode_str(input: &str) -> Result { let s: &str; let sign = if input.starts_with('-') { - s = &input.strip_prefix('-').unwrap(); + s = input.strip_prefix('-').unwrap(); Sign::Minus } else if input.starts_with('+') { - s = &input.strip_prefix('+').unwrap(); + s = input.strip_prefix('+').unwrap(); Sign::Plus } else { s = input;