Skip to content
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

Merged
merged 2 commits into from
Jan 10, 2017
Merged

Update vec.rs #38874

merged 2 commits into from
Jan 10, 2017

Conversation

richard-uk1
Copy link
Contributor

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.

Add a warning not to convert  char* from c to Vec<u8> (I thought you could until I asked on irc)
@rust-highfive
Copy link
Collaborator

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.

Copy link
Member

@steveklabnik steveklabnik left a 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`.
Copy link
Member

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.
@steveklabnik
Copy link
Member

@bors: r+ rollup

thank you!

@bors
Copy link
Contributor

bors commented Jan 6, 2017

📌 Commit 0a85d5f has been approved by steveklabnik

sanxiyn added a commit to sanxiyn/rust that referenced this pull request Jan 10, 2017
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.
bors added a commit that referenced this pull request Jan 10, 2017
Rollup of 11 pull requests

- Successful merges: #38606, #38607, #38623, #38664, #38799, #38816, #38836, #38839, #38841, #38849, #38874
- Failed merges: #38845
@bors bors merged commit 0a85d5f into rust-lang:master Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants