Skip to content

formalize FromStr syntax #32243

Closed
Closed
@flying-sheep

Description

@flying-sheep

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.

Activity

hanna-kruppe

hanna-kruppe commented on Mar 14, 2016

@hanna-kruppe
Contributor

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

added
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
and removed on Mar 23, 2017
frewsxcv

frewsxcv commented on Jun 8, 2017

@frewsxcv
Member

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

leoschwarz commented on Jun 8, 2017

@leoschwarz

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

flying-sheep commented on Jun 9, 2017

@flying-sheep
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?

steveklabnik

steveklabnik commented on Aug 30, 2017

@steveklabnik
Member

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

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@flying-sheep@frewsxcv@hanna-kruppe@Mark-Simulacrum

        Issue actions

          formalize FromStr syntax · Issue #32243 · rust-lang/rust