@@ -1227,10 +1227,7 @@ impl<T: FloatCore + Num> Num for OrderedFloat<T> {
1227
1227
/// ```
1228
1228
/// use ordered_float::NotNan;
1229
1229
///
1230
- /// let mut v = [
1231
- /// NotNan::new(2.0).unwrap(),
1232
- /// NotNan::new(1.0).unwrap(),
1233
- /// ];
1230
+ /// let mut v = [NotNan::new(2.0).unwrap(), NotNan::new(1.0).unwrap()];
1234
1231
/// v.sort();
1235
1232
/// assert_eq!(v, [1.0, 2.0]);
1236
1233
/// ```
@@ -1270,7 +1267,6 @@ impl<T: FloatCore + Num> Num for OrderedFloat<T> {
1270
1267
/// [transmute](core::mem::transmute) or pointer casts to convert between any type `T` and
1271
1268
/// `NotNan<T>`, as long as this does not create a NaN value.
1272
1269
/// However, consider using [`bytemuck`] as a safe alternative if possible.
1273
- ///
1274
1270
#[ cfg_attr(
1275
1271
not( feature = "bytemuck" ) ,
1276
1272
doc = "[`bytemuck`]: https://docs.rs/bytemuck/1/"
@@ -1384,9 +1380,10 @@ impl NotNan<f64> {
1384
1380
/// Note: For the reverse conversion (from `NotNan<f32>` to `NotNan<f64>`), you can use
1385
1381
/// `.into()`.
1386
1382
pub fn as_f32 ( self ) -> NotNan < f32 > {
1387
- // This is not destroying invariants, as it is a pure rounding operation. The only two special
1388
- // cases are where f32 would be overflowing, then the operation yields Infinity, or where
1389
- // the input is already NaN, in which case the invariant is already broken elsewhere.
1383
+ // This is not destroying invariants, as it is a pure rounding operation. The only two
1384
+ // special cases are where f32 would be overflowing, then the operation yields
1385
+ // Infinity, or where the input is already NaN, in which case the invariant is
1386
+ // already broken elsewhere.
1390
1387
NotNan ( self . 0 as f32 )
1391
1388
}
1392
1389
}
@@ -1473,14 +1470,14 @@ impl<T: FloatCore> PartialEq<T> for NotNan<T> {
1473
1470
/// Adds a float directly.
1474
1471
///
1475
1472
/// Panics if the provided value is NaN or the computation results in NaN
1476
- impl < T : FloatCore > Add < T > for NotNan < T > {
1473
+ /* impl<T: FloatCore> Add<T> for NotNan<T> {
1477
1474
type Output = Self;
1478
1475
1479
1476
#[inline]
1480
1477
fn add(self, other: T) -> Self {
1481
1478
NotNan::new(self.0 + other).expect("Addition resulted in NaN")
1482
1479
}
1483
- }
1480
+ }*/
1484
1481
1485
1482
/// Adds a float directly.
1486
1483
///
@@ -1501,26 +1498,26 @@ impl<'a, T: FloatCore + Sum + 'a> Sum<&'a NotNan<T>> for NotNan<T> {
1501
1498
/// Subtracts a float directly.
1502
1499
///
1503
1500
/// Panics if the provided value is NaN or the computation results in NaN
1504
- impl < T : FloatCore > Sub < T > for NotNan < T > {
1501
+ /* impl<T: FloatCore> Sub<T> for NotNan<T> {
1505
1502
type Output = Self;
1506
1503
1507
1504
#[inline]
1508
1505
fn sub(self, other: T) -> Self {
1509
1506
NotNan::new(self.0 - other).expect("Subtraction resulted in NaN")
1510
1507
}
1511
- }
1508
+ }*/
1512
1509
1513
1510
/// Multiplies a float directly.
1514
1511
///
1515
1512
/// Panics if the provided value is NaN or the computation results in NaN
1516
- impl < T : FloatCore > Mul < T > for NotNan < T > {
1513
+ /* impl<T: FloatCore> Mul<T> for NotNan<T> {
1517
1514
type Output = Self;
1518
1515
1519
1516
#[inline]
1520
1517
fn mul(self, other: T) -> Self {
1521
1518
NotNan::new(self.0 * other).expect("Multiplication resulted in NaN")
1522
1519
}
1523
- }
1520
+ }*/
1524
1521
1525
1522
impl < T : FloatCore + Product > Product for NotNan < T > {
1526
1523
fn product < I : Iterator < Item = NotNan < T > > > ( iter : I ) -> Self {
@@ -1535,6 +1532,7 @@ impl<'a, T: FloatCore + Product + 'a> Product<&'a NotNan<T>> for NotNan<T> {
1535
1532
}
1536
1533
}
1537
1534
1535
+ /*
1538
1536
/// Divides a float directly.
1539
1537
///
1540
1538
/// Panics if the provided value is NaN or the computation results in NaN
@@ -1557,7 +1555,7 @@ impl<T: FloatCore> Rem<T> for NotNan<T> {
1557
1555
fn rem(self, other: T) -> Self {
1558
1556
NotNan::new(self.0 % other).expect("Rem resulted in NaN")
1559
1557
}
1560
- }
1558
+ }*/
1561
1559
1562
1560
macro_rules! impl_not_nan_binop {
1563
1561
( $imp: ident, $method: ident, $assign_imp: ident, $assign_method: ident) => {
@@ -1566,25 +1564,26 @@ macro_rules! impl_not_nan_binop {
1566
1564
1567
1565
#[ inline]
1568
1566
fn $method( self , other: Self ) -> Self {
1569
- self . $method( other. 0 )
1567
+ NotNan :: new( self . 0. $method( other. 0 ) )
1568
+ . expect( "Operation on two NotNan resulted in NaN" )
1570
1569
}
1571
1570
}
1572
1571
1573
- impl <T : FloatCore > $imp<& T > for NotNan <T > {
1572
+ /* impl<T: FloatCore> $imp<&T> for NotNan<T> {
1574
1573
type Output = NotNan<T>;
1575
1574
1576
1575
#[inline]
1577
1576
fn $method(self, other: &T) -> Self::Output {
1578
1577
self.$method(*other)
1579
1578
}
1580
- }
1579
+ }*/
1581
1580
1582
1581
impl <T : FloatCore > $imp<& Self > for NotNan <T > {
1583
1582
type Output = NotNan <T >;
1584
1583
1585
1584
#[ inline]
1586
1585
fn $method( self , other: & Self ) -> Self :: Output {
1587
- self . $method( other. 0 )
1586
+ self . $method( * other)
1588
1587
}
1589
1588
}
1590
1589
@@ -1593,7 +1592,7 @@ macro_rules! impl_not_nan_binop {
1593
1592
1594
1593
#[ inline]
1595
1594
fn $method( self , other: Self ) -> Self :: Output {
1596
- ( * self ) . $method( other. 0 )
1595
+ ( * self ) . $method( * other)
1597
1596
}
1598
1597
}
1599
1598
@@ -1602,11 +1601,11 @@ macro_rules! impl_not_nan_binop {
1602
1601
1603
1602
#[ inline]
1604
1603
fn $method( self , other: NotNan <T >) -> Self :: Output {
1605
- ( * self ) . $method( other. 0 )
1604
+ ( * self ) . $method( other)
1606
1605
}
1607
1606
}
1608
1607
1609
- impl <T : FloatCore > $imp<T > for & NotNan <T > {
1608
+ /* impl<T: FloatCore> $imp<T> for &NotNan<T> {
1610
1609
type Output = NotNan<T>;
1611
1610
1612
1611
#[inline]
@@ -1636,19 +1635,19 @@ macro_rules! impl_not_nan_binop {
1636
1635
fn $assign_method(&mut self, other: &T) {
1637
1636
*self = (*self).$method(*other);
1638
1637
}
1639
- }
1638
+ }*/
1640
1639
1641
1640
impl <T : FloatCore + $assign_imp> $assign_imp for NotNan <T > {
1642
1641
#[ inline]
1643
1642
fn $assign_method( & mut self , other: Self ) {
1644
- ( * self ) . $assign_method ( other. 0 ) ;
1643
+ * self = ( * self ) . $method ( other) ;
1645
1644
}
1646
1645
}
1647
1646
1648
1647
impl <T : FloatCore + $assign_imp> $assign_imp<& Self > for NotNan <T > {
1649
1648
#[ inline]
1650
1649
fn $assign_method( & mut self , other: & Self ) {
1651
- ( * self ) . $assign_method ( other. 0 ) ;
1650
+ * self = ( * self ) . $method ( * other) ;
1652
1651
}
1653
1652
}
1654
1653
} ;
0 commit comments