Skip to content

Commit 338d056

Browse files
committedApr 27, 2024·
Release 0.15.2
1 parent aca926a commit 338d056

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [0.15.2] - 2024-04-28
4+
### Added
5+
- GenericFraction ConstOne and ConstZero trait implementations (special thanks to Raimundo Saona, aka @saona-raimundo)
6+
37
## [0.15.1] - 2024-02-11
48
### Added
59
- "with-unicode" feature implementation to format (and parse) floats with Unicode characters (special thanks to @feefladder)

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fraction"
3-
version = "0.15.1"
3+
version = "0.15.2"
44
authors = ["dnsl48 <dnsl48@gmail.com>"]
55

66
description = "Lossless fractions and decimals; drop-in float replacement"

‎src/fraction/generic_fraction.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::fraction::Sign;
22
use crate::{
3-
display, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, ConstOne, ConstZero, FromPrimitive, Integer, Num,
4-
One, ParseRatioError, Ratio, Signed, ToPrimitive, Zero,
3+
display, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, ConstOne, ConstZero,
4+
FromPrimitive, Integer, Num, One, ParseRatioError, Ratio, Signed, ToPrimitive, Zero,
55
};
66
#[cfg(feature = "with-bigint")]
77
use crate::{BigInt, BigUint};
@@ -595,7 +595,8 @@ impl<T: Clone + Integer> Zero for GenericFraction<T> {
595595
}
596596

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

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

607608
impl<T: ConstOne + Integer + Clone> ConstOne for GenericFraction<T> {
608-
const ONE: GenericFraction<T> = GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE));
609+
const ONE: GenericFraction<T> =
610+
GenericFraction::Rational(Sign::Plus, Ratio::new_raw(ConstOne::ONE, ConstOne::ONE));
609611
}
610612

611613
impl<T: Clone + Integer> Num for GenericFraction<T> {
@@ -1264,7 +1266,10 @@ mod tests {
12641266
#[cfg(feature = "with-bigint")]
12651267
use crate::{BigInt, BigUint};
12661268

1267-
use crate::{Bounded, ConstOne, ConstZero, Fraction, GenericFraction, Num, One, Sign, Signed, ToPrimitive, Zero};
1269+
use crate::{
1270+
Bounded, ConstOne, ConstZero, Fraction, GenericFraction, Num, One, Sign, Signed,
1271+
ToPrimitive, Zero,
1272+
};
12681273

12691274
use super::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub};
12701275

@@ -2715,14 +2720,14 @@ mod tests {
27152720
let one = Frac::one();
27162721
assert_eq!(constant_one, one);
27172722
}
2718-
2723+
27192724
#[test]
27202725
fn constant_zero() {
27212726
let constant_zero = <Frac as ConstZero>::ZERO;
27222727
let zero = Frac::zero();
27232728
assert_eq!(constant_zero, zero);
27242729
}
2725-
2730+
27262731
#[test]
27272732
fn consistency_partial_cmp() {
27282733
let nan = Frac::nan();

‎src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ pub use num::bigint::{BigInt, BigUint};
224224
pub use num::rational::{ParseRatioError, Ratio};
225225

226226
pub use num::{
227+
traits::{ConstOne, ConstZero},
227228
Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Integer, Num, One,
228-
Signed, ToPrimitive, traits::{ConstOne, ConstZero}, Zero,
229+
Signed, ToPrimitive, Zero,
229230
};
230231

231232
#[cfg(test)]

0 commit comments

Comments
 (0)
Please sign in to comment.