Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formalize FromStr syntax #32243

Closed
flying-sheep opened this issue Mar 14, 2016 · 5 comments
Closed

formalize FromStr syntax #32243

flying-sheep opened this issue Mar 14, 2016 · 5 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@flying-sheep
Copy link

AFAIK there’s no grammar specified anywhere that describes how FromStr/parse works.

E.g. some didn’t want f64::from_str(".") to work (#30344) and I wonder why i32::from_str("1_000") does not work.

@hanna-kruppe
Copy link
Contributor

At least for float parsing there are comments on the impl FromStr but they are incomplete and probably not rendered by rustdoc.

@steveklabnik steveklabnik added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-docs labels Mar 23, 2017
@frewsxcv
Copy link
Member

frewsxcv commented Jun 8, 2017

probably not rendered by rustdoc.

The comments are now rendered by rustdoc: https://doc.rust-lang.org/std/primitive.f32.html (scroll down to FromStr). Anyone have suggestions for what to add to those docs? Do we even have a grammar for parsing floats?

@leoschwarz
Copy link

leoschwarz commented Jun 8, 2017

I didn't find a grammar for FromStr for floats however as most likely it would be a bad idea to change the parsing now, it could just be derived from the code and officially documented so users don't have to figure these things out themselves.

Maybe as grammar language what was used for the Rust grammar specification could be used, i.e. maybe link that and provide an expression for the valid numbers? Specifically I think it won't be too far away from this.

@flying-sheep
Copy link
Author

it would be a bad idea to change the parsing now

i’d like parsing to be more lenient and accept underscores, i guess you only meant parsing shouldn’t get stricter?

@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 24, 2017
@steveklabnik
Copy link
Member

This is a special case of #31821, so closing as part of that.

frewsxcv added a commit to frewsxcv/rust that referenced this issue Nov 25, 2018
- Original bug about documenting grammar
  - rust-lang#32243
- Known bug with parsing
  - rust-lang#31407
Centril added a commit to Centril/rust that referenced this issue Jan 25, 2019
…ietMisdreavus

Add grammar in docs for {f32,f64}::from_str, mention known bug.

- Original bug about documenting grammar
  - rust-lang#32243
- Known bug with parsing
  - rust-lang#31407
VardhanThigle pushed a commit to jethrogb/rust that referenced this issue Jan 31, 2019
- Original bug about documenting grammar
  - rust-lang#32243
- Known bug with parsing
  - rust-lang#31407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants