Number types' `FromStr` impl should recognize Unicode minus
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
You can say the following about the character currently exclusively recognized as minus by FromStr impls:
- Its official Unicode name is
U+002D HYPHEN-MINUS : hyphen, dash, minus sign(copied from BabelMap). - The general typographical reality of font designs is that it's a hyphen and not a minus sign.
- The usage-wise reality is that it's widely used as a replacement character for a real minus sign.
In comparison, U+2212 is a dedicated minus sign:
- Official Unicode name:
U+2212 MINUS SIGN - Matches the horizontal bar of a plus sign.
- GitHub, e.g., uses it to display the red "lines deleted" values. Wikipedia and LaTeX equation renderings also use it.
- In HTML, you have the entity
−for it.
Benefits of adding support:
- If the
FromStrimplementations of number types (i32,f64etc.) would supportU+2212 MINUS SIGNin addition toU+002D HYPHEN-MINUSas a minus sign, UI frameworks, e.g., would have an easier time implementing text boxes that display the typographically more pleasing real minus sign, simply converting the text content to the corresponding number. - App implementations not further checking user input, but directly trying to parse it as a number, and banking on the returned
Result, wouldn't confuse end users anymore when they pasted a number with Unicode minus into the app and the app showed an error. - Also, since it's a dedicated minus sign, and not just a common replacement character, it logically follows in my opinion that it should be supported.
I'm not familiar with this, but I want to point out that the Wikipedia article "Plus and minus signs" also talks about ⁒ as a minus sign (U+2052 COMMERCIAL MINUS SIGN). Perhaps, this should also be supported. But I don't know whether it's regularly set off from the number with some space character.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the FromStr implementations for Rust's number types and their parsing tests. Determine whether support should cover U+2212 only or also U+2052, then update the relevant behavior and tests so accepted Unicode minus input parses successfully without changing unrelated formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100