Format a float in Python style (ensures trailing .0 for integers).
(value: f64)
| 941 | |
| 942 | /// Format a float in Python style (ensures trailing .0 for integers). |
| 943 | fn float_repr(value: f64) -> String { |
| 944 | if value.is_nan() { |
| 945 | "nan".to_owned() |
| 946 | } else if value.is_infinite() { |
| 947 | if value.is_sign_positive() { |
| 948 | "inf".to_owned() |
| 949 | } else { |
| 950 | "-inf".to_owned() |
| 951 | } |
| 952 | } else { |
| 953 | let s = format!("{}", value); |
| 954 | // If no decimal point and not in scientific notation, add .0 |
| 955 | if !s.contains('.') && !s.contains('e') && !s.contains('E') { |
| 956 | format!("{}.0", s) |
| 957 | } else { |
| 958 | s |
| 959 | } |
| 960 | } |
| 961 | } |
nothing calls this directly
no test coverage detected