Follow

okay, rust nerds: what's the equivalent of `strtol` in Rust? That is to say, I want to parse decimal, octal, or hexidecimal representations of an integer like a normal person. Do I seriously have to use libc::strtol?

A little more detail: right now I'm using clap to parse the cli. It defaults to using FromStr to parse the int, but of course FromStr doesn't handle hex/octal/etc because of course it doesn't

@hub strtol will interpret the string as hex if it begins with 0x, octal if it begins with 0, decimal otherwise. This doesn't do any such interpretation

Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!