pacman82 / atoi-rs

Parse integers directly from `[u8]` slices in safe code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fail to parse negative number

photoszzt opened this issue · comments

atoi::<i64>(b"-123")

the above code returns None instead of Some(-123).

Oh, it's not supported.

Maybe it should be, though 🤔

I wish this could be supported.

The next time I can squeeze in some Open Source work I'll add support. Probably first as a non breaking additional function, and then let's see how we take things from there.

Parsing negative integers (and nonnegatives with + Sign) is now supported via FromRadix10Signed and FromRadix10SignedChecked.

Question is, if we should make this the "default" behaviour, by using FromRadix10SignedChecked in the atoi function instead of FromRadix10Checked?

Parsing with support for signs is now the 'default'. Closing this issue.