Skip to content

Commit 15290fa

Browse files
committed
add NaN examples to public min/max functions
1 parent 8b87b25 commit 15290fa

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

library/core/src/num/f128.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ impl f128 {
709709
/// let y = 2.0f128;
710710
///
711711
/// assert_eq!(x.max(y), y);
712+
/// assert_eq!(x.max(f128::NAN), x);
712713
/// # }
713714
/// ```
714715
#[inline]
@@ -736,6 +737,7 @@ impl f128 {
736737
/// let y = 2.0f128;
737738
///
738739
/// assert_eq!(x.min(y), x);
740+
/// assert_eq!(x.min(f128::NAN), x);
739741
/// # }
740742
/// ```
741743
#[inline]

library/core/src/num/f16.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ impl f16 {
701701
/// let y = 2.0f16;
702702
///
703703
/// assert_eq!(x.max(y), y);
704+
/// assert_eq!(x.max(f16::NAN), x);
704705
/// # }
705706
/// ```
706707
#[inline]
@@ -727,6 +728,7 @@ impl f16 {
727728
/// let y = 2.0f16;
728729
///
729730
/// assert_eq!(x.min(y), x);
731+
/// assert_eq!(x.min(f16::NAN), x);
730732
/// # }
731733
/// ```
732734
#[inline]

library/core/src/num/f32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ impl f32 {
908908
/// let y = 2.0f32;
909909
///
910910
/// assert_eq!(x.max(y), y);
911+
/// assert_eq!(x.max(f32::NAN), x);
911912
/// ```
912913
#[must_use = "this returns the result of the comparison, without modifying either input"]
913914
#[stable(feature = "rust1", since = "1.0.0")]
@@ -930,6 +931,7 @@ impl f32 {
930931
/// let y = 2.0f32;
931932
///
932933
/// assert_eq!(x.min(y), x);
934+
/// assert_eq!(x.min(f32::NAN), x);
933935
/// ```
934936
#[must_use = "this returns the result of the comparison, without modifying either input"]
935937
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/num/f64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ impl f64 {
926926
/// let y = 2.0_f64;
927927
///
928928
/// assert_eq!(x.max(y), y);
929+
/// assert_eq!(x.max(f64::NAN), x);
929930
/// ```
930931
#[must_use = "this returns the result of the comparison, without modifying either input"]
931932
#[stable(feature = "rust1", since = "1.0.0")]
@@ -948,6 +949,7 @@ impl f64 {
948949
/// let y = 2.0_f64;
949950
///
950951
/// assert_eq!(x.min(y), x);
952+
/// assert_eq!(x.min(f64::NAN), x);
951953
/// ```
952954
#[must_use = "this returns the result of the comparison, without modifying either input"]
953955
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)