Skip to content

Commit

Permalink
Release 0.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsl48 committed Apr 27, 2024
1 parent aca926a commit 338d056
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions 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)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "fraction"
version = "0.15.1"
version = "0.15.2"
authors = ["dnsl48 <dnsl48@gmail.com>"]

description = "Lossless fractions and decimals; drop-in float replacement"
Expand Down
19 changes: 12 additions & 7 deletions 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};
Expand Down Expand Up @@ -595,7 +595,8 @@ impl<T: Clone + Integer> Zero for GenericFraction<T> {
}

impl<T: ConstOne + ConstZero + Integer + Clone> ConstZero for GenericFraction<T> {
const ZERO: GenericFraction<T> = GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstZero::ZERO, ConstOne::ONE));
const ZERO: GenericFraction<T> =
GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstZero::ZERO, ConstOne::ONE));
}

impl<T: Clone + Integer> One for GenericFraction<T> {
Expand All @@ -605,7 +606,8 @@ impl<T: Clone + Integer> One for GenericFraction<T> {
}

impl<T: ConstOne + Integer + Clone> ConstOne for GenericFraction<T> {
const ONE: GenericFraction<T> = GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE));
const ONE: GenericFraction<T> =
GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE));
}

impl<T: Clone + Integer> Num for GenericFraction<T> {
Expand Down Expand Up @@ -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};

Expand Down Expand Up @@ -2715,14 +2720,14 @@ mod tests {
let one = Frac::one();
assert_eq!(constant_one, one);
}

#[test]
fn constant_zero() {
let constant_zero = <Frac as ConstZero>::ZERO;
let zero = Frac::zero();
assert_eq!(constant_zero, zero);
}

#[test]
fn consistency_partial_cmp() {
let nan = Frac::nan();
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Expand Up @@ -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)]
Expand Down

0 comments on commit 338d056

Please sign in to comment.