diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eb9a8f4..621921f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [0.15.2] - 2024-04-28 +### Added + - GenericFraction ConstOne and ConstZero trait implementations (special thanks to Raimundo Saona, aka @saona-raimundo) + ## [0.15.1] - 2024-02-11 ### Added - "with-unicode" feature implementation to format (and parse) floats with Unicode characters (special thanks to @feefladder) diff --git a/Cargo.toml b/Cargo.toml index e66359be..9c36e36a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fraction" -version = "0.15.1" +version = "0.15.2" authors = ["dnsl48 "] description = "Lossless fractions and decimals; drop-in float replacement" diff --git a/src/fraction/generic_fraction.rs b/src/fraction/generic_fraction.rs index cb3bc0cd..e337e6d8 100644 --- a/src/fraction/generic_fraction.rs +++ b/src/fraction/generic_fraction.rs @@ -1,7 +1,7 @@ use crate::fraction::Sign; use crate::{ - display, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, ConstOne, ConstZero, FromPrimitive, Integer, Num, - One, ParseRatioError, Ratio, Signed, ToPrimitive, Zero, + display, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, ConstOne, ConstZero, + FromPrimitive, Integer, Num, One, ParseRatioError, Ratio, Signed, ToPrimitive, Zero, }; #[cfg(feature = "with-bigint")] use crate::{BigInt, BigUint}; @@ -595,7 +595,8 @@ impl Zero for GenericFraction { } impl ConstZero for GenericFraction { - const ZERO: GenericFraction = GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstZero::ZERO, ConstOne::ONE)); + const ZERO: GenericFraction = + GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstZero::ZERO, ConstOne::ONE)); } impl One for GenericFraction { @@ -605,7 +606,8 @@ impl One for GenericFraction { } impl ConstOne for GenericFraction { - const ONE: GenericFraction = GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE)); + const ONE: GenericFraction = + GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE)); } impl Num for GenericFraction { @@ -1264,7 +1266,10 @@ mod tests { #[cfg(feature = "with-bigint")] use crate::{BigInt, BigUint}; - use crate::{Bounded, ConstOne, ConstZero, Fraction, GenericFraction, Num, One, Sign, Signed, ToPrimitive, Zero}; + use crate::{ + Bounded, ConstOne, ConstZero, Fraction, GenericFraction, Num, One, Sign, Signed, + ToPrimitive, Zero, + }; use super::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub}; @@ -2715,14 +2720,14 @@ mod tests { let one = Frac::one(); assert_eq!(constant_one, one); } - + #[test] fn constant_zero() { let constant_zero = ::ZERO; let zero = Frac::zero(); assert_eq!(constant_zero, zero); } - + #[test] fn consistency_partial_cmp() { let nan = Frac::nan(); diff --git a/src/lib.rs b/src/lib.rs index 00a05935..d39cf1a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -224,8 +224,9 @@ pub use num::bigint::{BigInt, BigUint}; pub use num::rational::{ParseRatioError, Ratio}; pub use num::{ + traits::{ConstOne, ConstZero}, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Integer, Num, One, - Signed, ToPrimitive, traits::{ConstOne, ConstZero}, Zero, + Signed, ToPrimitive, Zero, }; #[cfg(test)]