-
Notifications
You must be signed in to change notification settings - Fork 340
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
Could rust::Vec::set_len
be public API?
#990
Comments
How is this API done in std::vector or other C++ vector libraries? |
As best as I can tell, the answer for
Caveat: It's been a long time since I've seriously written C++. I'm certainly not an expert on this. |
Here's a StackOverflow that addresses this directly: https://stackoverflow.com/a/61450370. The tl;dr is the idiom of reserving space in a |
I'm writing some code in C++ that reserves space in a
rust::Vec
, initializes the new chunk of memory, and then wants to callrust::Vec::set_len
to indicate that the new elements are now valid. That's obviously "unsafe" from Rust's perspective but doesn't seem particularly more dangerous than any other C++ code. Butrust::Vec::set_len
is currently private, presumably for a reason! Thoughts on making it public? Perhaps with anunsafe
prefix, as inunsafe_set_len
?Note: not blocked on this, since I've got this workaround:
The text was updated successfully, but these errors were encountered: