Skip to content

from_str_radix hex "+" pitfall #16213

@Rudxain

Description

@Rudxain

Description

This seems like a common mistake. It consists on using code like this:

uN::from_str_radix(hex_slice, 16)

to decode a hexadecimal string into an integer, unintentionally (in most cases) allowing + as a valid prefix for hex sequences. I say "unintentional" because hex-strs typically represent arbitrary data, not numbers/numerals.

Note

Prev paragraph was edited for clarity

IDK if there's an existing lint-rule where this should be included, or if it warrants a new lint, that's why I've opened a blank issue

Version


Additional Labels

@rustbot label +C-enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions