Skip to content

Leading plus for string to integer parsing #27580

Closed
@Cigaes

Description

@Cigaes

The parse::<i32>() function (and all its cousins for other integer types) fail for strings starting with a + with ParseIntError { kind: InvalidDigit }. Failing snippet:

fn main () {
  assert_eq!("+42".parse::<i32>().unwrap(), 42);
}

The same error occurs with the symmetric function call i32::from_str("+42").

Test snippet on Rust Playground
Rust Forum discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-needs-decisionIssue: In need of a decision.P-lowLow priorityT-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

    Issue actions