Closed jwodder closed 7 months ago
For context, I started off avoiding usize / isize because of their platform-specific nature, instead wanting people to pick a cross-platform data type to parse and then convert to what type is needed within their application. This is more important in winnow::binary
but also carried over into winnow::ascii
.
So are you currently willing to add usize
support to winnow::ascii
? In the code I'm writing, the integers I'm parsing are solely going to be used for things that Rust requires usize
for, such as Vec
lengths & indices and take()
arguments. I'd like to be able to parse exactly those integers that fit into a usize
without having to convert through a fixed-size integer type, which wouldn't cover the full range on some platforms and/or (particularly if I went with u128
) would be wasteful on most platforms.
Please complete the following tasks
winnow version
0.5.34
Describe your use case
I would like to use
winnow
to parse some unsigned decimal integers intousize
, butwinnow::ascii::dec_uint()
does not support that, asusize
does not implementwinnow::ascii::Uint
.I do not know whether this was simply an oversight or whether
usize
was deliberately excluded from the trait, but as I can find no references to parsingusize
in the issues or discussions, in the worst case scenario (for me), this issue can be used to document why it's not implemented.(I am aware I can do
digit1.parse_to()
, but if I'm supposed to use that, then why havedec_uint()
at all? I am also aware I can usedec_uint()
to parse a fixed-size int and then try-convert that tousize
, but that's less convenient than ifdec_uint()
supportedusize
in the first place.)Describe the solution you'd like
impl Uint for usize
Alternatives, if applicable
No response
Additional Context
No response