Skip to content

from_str_radix panics for some values of radix #42034

Closed
@BurntSushi

Description

@BurntSushi

The from_str_radix methods on the various number types panics if radix < 2 or if radix > 36: https://doc.rust-lang.org/src/core/num/mod.rs.html#2693

I think we should fix this through one of two means:

  1. Decide that it is a contract violation and document the cases where the function panics.
  2. Decide that it is a normal error, be thankful that the ParseIntError internals aren't exposed, and return an error when radix is invalid. Finally, document the error condition.

cc @rust-lang/libs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-needs-decisionIssue: In need of a decision.S-waiting-on-teamStatus: Awaiting decision from the relevant subteam (see the T-<team> label).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

    Issue actions