Closed
Description
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
hanna-kruppe commentedon Mar 14, 2016
At least for float parsing there are comments on the
impl FromStr
but they are incomplete and probably not rendered by rustdoc.".e0".parse()
returnsOk(0.0)
#40654frewsxcv commentedon Jun 8, 2017
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 commentedon 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 commentedon Jun 9, 2017
i’d like parsing to be more lenient and accept underscores, i guess you only meant parsing shouldn’t get stricter?
steveklabnik commentedon Aug 30, 2017
This is a special case of #31821, so closing as part of that.
5 remaining items