-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support other radix #15
Comments
Check out the implementation and discussion in rust-lang/rust#46281 -- some promising ideas there as well. |
Ultimately, I do need something that can push to a fmt::Write, though. |
Note that with specialization, there's a "cheap" thing that |
@dtolnay I'd be happy to furnish code from rust-lexical, which supports this functionality, to do just that. |
I am leaning toward keeping itoa focused on base 10. Is rust-lexical already usable as an itoa replacement if someone needs a different radix? That would be best. Otherwise maybe one of you could maintain a fork of itoa or make a new crate that does non-base-10. |
@dtolnay Yes, it supports all radices (with the radix feature, only base10 by default) and has similar performance to itoa, so it's definitely a viable alternative. So if this feature isn't desired, I'd recommend just using that. If you ever want to support other radices, I'd love to give commits forward: you've contributed so much to the ecosystem, the least I can do is pay a small fraction of that back. |
I'm interested in hexadecimal output in the same vein as itoa::fmt, and to do that I've extracted the code from libcore.
The C function itoa takes an argument for the radix, so I thought it would make sense to add the code to this crate, if you're interested. The question is what should the API look like. libcore provides a few traits for Binary, Octal, and Hexa, I think it would make sense to expose similarly named traits with the same functions as in the
itoa::Integer
trait.What do you think?
The text was updated successfully, but these errors were encountered: