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 doc for Vec::into_boxed_slice #137546

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heiseish
Copy link
Contributor

Context

  • Update the doc for Vec::into_boxed_slice to highlight the API dependency on the memory layout strategy, and the doctest to remove the "encoding" of exact capacity guarantee.

Related issue

r? @the8472

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 24, 2025
@workingjubilee
Copy link
Member

also note #135933

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

/// assert_eq!(slice.into_vec().capacity(), 3);
/// let new_vec = slice.into_vec();
/// // The allocator may have kept extra capacity:
/// assert!(new_vec.capacity() >= 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about the test. I tried many times with assert_eq!(slice.into_vec().capacity(), 3);, it all passed. And I tested it for different types and cases. Only ZST kept extra capacity. Experiment result is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants