Skip to content

f32::from_str and f64::from_str: parser returned error on just a '.' (a dot) #44242

@kamarkiewicz

Description

@kamarkiewicz

Hi! I found a mismatch between documentation and behavior of stable Rust.
When I tried to parse a string equal "." f32/f64::from_str returned Err(...) instead of Ok(0.0), as it states in official documentation here.

Tests (based on mentioned doc)

f32: https://play.rust-lang.org/?gist=c7495df140e0991473fb914b0b468b34&version=stable
f64: https://play.rust-lang.org/?gist=c319d2f10762767b9983907cb9d7f2dc&version=stable

Activity

hanna-kruppe

hanna-kruppe commented on Sep 1, 2017

@hanna-kruppe
Contributor

This is a docs issue. The libs team decided in #30344 to consider "." an invalid input instead of parsing it as 0.

added
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Sep 1, 2017
steveklabnik

steveklabnik commented on Sep 1, 2017

@steveklabnik
Member

I'd be happy to mentor anyone who wants to fix this, it'd be a great first bug!

mcomstock

mcomstock commented on Sep 1, 2017

@mcomstock
Contributor

I'd like to work on this.

Freyskeyd

Freyskeyd commented on Sep 4, 2017

@Freyskeyd
Contributor

@mcomstock are you fixing this?

mcomstock

mcomstock commented on Sep 4, 2017

@mcomstock
Contributor

Yeah! Sorry for the delay.

Freyskeyd

Freyskeyd commented on Sep 4, 2017

@Freyskeyd
Contributor

@mcomstock ok let me know if you need help

added 2 commits that reference this issue on Sep 6, 2017
adcc1f0
e7470c9
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-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@shepmaster@kamarkiewicz@Freyskeyd@hanna-kruppe

        Issue actions

          `f32::from_str` and `f64::from_str`: parser returned error on just a '.' (a dot) · Issue #44242 · rust-lang/rust