@@ -21,19 +21,34 @@ pub(crate) enum MinMax {
21
21
/// readability.
22
22
///
23
23
/// ## Example
24
+ ///
24
25
/// ```python
25
26
/// minimum = min(1, 2, min(3, 4, 5))
26
27
/// maximum = max(1, 2, max(3, 4, 5))
27
28
/// diff = maximum - minimum
28
29
/// ```
29
30
///
30
31
/// Use instead:
32
+ ///
31
33
/// ```python
32
34
/// minimum = min(1, 2, 3, 4, 5)
33
35
/// maximum = max(1, 2, 3, 4, 5)
34
36
/// diff = maximum - minimum
35
37
/// ```
36
38
///
39
+ /// ## Fix safety
40
+ ///
41
+ /// This fix is always unsafe and may change the program's behavior for types without full
42
+ /// equivalence relations, such as float comparisons involving `NaN`.
43
+ ///
44
+ /// ```python
45
+ /// print(min(2.0, min(float("nan"), 1.0))) # before fix: 2.0
46
+ /// print(min(2.0, float("nan"), 1.0)) # after fix: 1.0
47
+ ///
48
+ /// print(max(1.0, max(float("nan"), 2.0))) # before fix: 1.0
49
+ /// print(max(1.0, float("nan"), 2.0)) # after fix: 2.0
50
+ /// ```
51
+ ///
37
52
/// ## References
38
53
/// - [Python documentation: `min`](https://docs.python.org/3/library/functions.html#min)
39
54
/// - [Python documentation: `max`](https://docs.python.org/3/library/functions.html#max)
0 commit comments