diff options
author | Yuki Okushi <jtitor@2k36.org> | 2022-06-01 23:36:49 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 23:36:49 +0900 |
commit | e1d2e65463e9bc5b75f92209a9e22a6ba7b7aa24 (patch) | |
tree | 04f4f0d5bb62a2ff05cd1e3af92ffc6ae1bc69f8 | |
parent | a1dc541c69bcd657eb42406a367663fed2a3b0e2 (diff) | |
parent | 0484cfb6a91d1236809cfe4c536aa29b498e518d (diff) | |
download | rust-e1d2e65463e9bc5b75f92209a9e22a6ba7b7aa24.tar.gz |
Rollup merge of #97498 - ijchen:master, r=Mark-Simulacrum
Corrected EBNF grammar for from_str
Hello! This is my first time contributing to an open-source project. I'm excited to have the chance to contribute to the rust community 🥳
I noticed an issue with the documentation for `from_str` in `f32` and `f64`. It states that "All strings that adhere to the following [EBNF](https://www.w3.org/TR/REC-xml/#sec-notation) grammar when lowercased will result in an `Ok` being returned. I believe this is incorrect for the string `"."`, which is valid for the given EBNF grammar, but does not result in an `Ok` being returned ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=09f891aa87963a56d3b0d715d8cbc2b4)). I have simplified the grammar in a way which fixes that, but is otherwise identical.
Previously, the `Number` part of the EBNF grammar had an option for `'.' Digit*`, which would include the string `"."`. This is not valid, and does not return an Ok as stated. The corrected version removes this, and still allows for the `'.' Digit+` case with the already existing `Digit* '.' Digit+` case.
-rw-r--r-- | library/core/src/num/dec2flt/mod.rs | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index df0e7431f1f..a888ced49b3 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -126,7 +126,6 @@ macro_rules! from_str_float_impl { /// ```txt /// Float ::= Sign? ( 'inf' | 'infinity' | 'nan' | Number ) /// Number ::= ( Digit+ | - /// '.' Digit* | /// Digit+ '.' Digit* | /// Digit* '.' Digit+ ) Exp? /// Exp ::= 'e' Sign? Digit+ |