Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations & fix lints #111

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fraction"
version = "0.15.3"
version = "0.16.0"
authors = ["dnsl48 <[email protected]>"]

description = "Lossless fractions and decimals; drop-in float replacement"
Expand All @@ -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 }
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/decimal/postgres_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
19 changes: 9 additions & 10 deletions src/dynaint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// ```
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -916,7 +915,7 @@ where
T: Copy + GenericInteger + Into<G> + TryToConvertFrom<G> + From<u8> + ToBigUint,
G: Clone + GenericInteger + ToBigUint,
{
fn to_biguint(&self) -> Option<num::BigUint> {
fn to_biguint(&self) -> Option<BigUint> {
match self {
DynaInt::S(s) => s.to_biguint(),
DynaInt::__H(h) => h.to_biguint(),
Expand All @@ -943,7 +942,7 @@ mod tests {

#[test]
fn growth() {
let m8 = u8::max_value();
let m8 = u8::MAX;

let mut val = D::from(m8);

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/fraction/approx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ impl Accuracy {
/// printed as binary".
///
/// Prefer using [`Accuracy::decimal_places`] when `base == 10`.
pub fn base_places<B: GenericInteger, N: GenericInteger>(base: B, n: N) -> Self
pub fn base_places<B, N: GenericInteger>(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<BigUint>,
B: Into<BigUint> + GenericInteger,

// We need to be able to raise `BigUint(base)` to the power of `n`...
BigUint: Pow<N>,
Expand Down
4 changes: 2 additions & 2 deletions src/fraction/unicode_str_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ impl<T: Clone + Integer + From<u8>> GenericFraction<T> {
pub fn from_unicode_str(input: &str) -> Result<Self, ParseError> {
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;
Expand Down
Loading