-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Document that slice refers to any pointer type to a sequence #75028
Conversation
Also document that slices are twice as large as pointers to Sized types
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (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.
I am not comfortable with approving this myself.
I think someone from the docs
team should look over this
r? @steveklabnik to review/reassign |
@MrModder any updates on this? |
This reverts part of commit e6c83dd. As requested by @steveklabnik .
@Dylan-DPC . The changes to the first paragraph are now reverted. Hopefully the PR can be merged now. |
@bors: r+ rollup thank you! Sorry this took a while :/ |
📌 Commit cf76256 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
I was recently confused about the way slices are represented in memory. The necessary information was not available in the std-docs directly, but was a mix of different material from the reference and book.
This PR should clear up the definition of slices a bit more in the documentation. Especially the fact that the term slice refers to the pointer/reference type, e.g.
&[T]
, and not[T]
.It also documents that slice pointers are twice the size of pointers to
Sized
types, as this concept may be unfamiliar to users coming from other languages that do not have the concept of "fat pointers" (especially C/C++).I've documented why this was important to me and my findings in this blog post.
r? @lcnr