core/num: Implement feature float_nan_to - #161250
Open
okaneco wants to merge 1 commit into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
clarfonthey
reviewed
Aug 17, 2026
Comment on lines
+1606
to
+1607
| /// Returns `self` if the value is a number, otherwise returns `replacement` | ||
| /// if `self` is NaN. |
Contributor
There was a problem hiding this comment.
I would prefer the wording: "is not NaN" even though "number" feels like the right choice for the opposite of "not a number", since we use the term "number" across the rest of the float docs to just mean any float.
Also, "number" could be misinterpreted to exclude all non-finite values even though explicitly NaN is excluded.
Contributor
Author
There was a problem hiding this comment.
Sure, coming up with phrasing in line with the style of the rest of the docs was awkward.
Addressed in latest commit.
Contributor
|
Minor docs nit, otherwise looks good to me. |
Add function `nan_to` on floats which replaces NaN values with a user-specified value or returns the original value if it is not a NaN.
Contributor
|
Looks good, thank you! @bors r+ rollup |
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Aug 18, 2026
core/num: Implement feature `float_nan_to` Accepted ACP: rust-lang/libs-team#787 Tracking issue: rust-lang#161248 Add function `nan_to` on `f16`, `f32`, `f64`, `f128` which replaces NaN values with a user-specified value or returns the original value if it is not a NaN. --- No LLM use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accepted ACP: rust-lang/libs-team#787
Tracking issue: #161248
Add function
nan_toonf16,f32,f64,f128which replaces NaN values with a user-specified value or returns the original value if it is not a NaN.No LLM use.