-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Update vec.rs #38874
Update vec.rs #38874
Conversation
Add a warning not to convert char* from c to Vec<u8> (I thought you could until I asked on irc)
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one tiny nit. Thank you!
@@ -370,7 +370,8 @@ impl<T> Vec<T> { | |||
/// * `capacity` needs to be the capacity that the pointer was allocated with. | |||
/// | |||
/// Violating these may cause problems like corrupting the allocator's | |||
/// internal datastructures. | |||
/// internal datastructures. For example it is **not** safe | |||
/// to build a `Vec<u8>` from a C pointer to a char array and a `size_t`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you put graves on the char
as well, please?
Changed language to stress char is the C meaning (u8) not unicode.
@bors: r+ rollup thank you! |
📌 Commit 0a85d5f has been approved by |
Update vec.rs Add a warning not to convert char* from c to Vec<u8> (I thought you could until I asked on irc). Reasoning is that it will help people avoid an error that could cause crashes and undefined behaviour. Only drawback is that it could confuse someone not familiar with C, but beginners are unlikely to be using this function anyway.
Add a warning not to convert char* from c to Vec (I thought you could until I asked on irc).
Reasoning is that it will help people avoid an error that could cause crashes and undefined behaviour. Only drawback is that it could confuse someone not familiar with C, but beginners are unlikely to be using this function anyway.