-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Expose a safe way to efficiently write to an uninitialized, fixed buffer #19
Comments
I like the API in ryu a lot. I would be on board with picking that up here. Please send a PR! In your use case is it important to use the smallest possible buffer for each integer type or can we just use |
I wouldn't say it is important (bench first and all) but my first thought was just to expose the max size. Other than that it would make it possible to preserve the current internal api which has the explicit per integer sizes so I figured why not do that tiny bit of optimization. |
I would go with |
Currently if I need to write an integer to a fixed size buffer I need to lookup how large of a buffer I need for the integer size and create it manually, either with zero initialization or unsafe. Further this buffer will not be directly written to as the crate creates its own buffer.
If the crate exposed a buffer type like https://docs.rs/ryu/0.2.6/ryu/struct.Buffer.html this could be avoided and hidden behind a safe interface.
Since associated constants are a relatively new Rust feature this could need some build.rs trickery and/or an extension trait but I'd be willing to submit a PR if this seems reasonable.
The text was updated successfully, but these errors were encountered: