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

Misleading doc about Vec::into_boxed_slice #98908

Closed
ark0f opened this issue Jul 5, 2022 · 3 comments · Fixed by #105032
Closed

Misleading doc about Vec::into_boxed_slice #98908

ark0f opened this issue Jul 5, 2022 · 3 comments · Fixed by #105032
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools

Comments

@ark0f
Copy link

ark0f commented Jul 5, 2022

Location

Vec::into_boxed_slice
impl From<Vec<T>> for Box<[T]>

Summary

impl From<Vec<T>> for Box<[T]> says:

If v has excess capacity, its items will be moved into a newly-allocated buffer with exactly the right capacity.

When Vec::into_boxed_slice does not:

Note that this will drop any excess capacity.

Despite the fact that impl From<Vec<T>> for Box<[T]> uses Vec::into_boxed_slice inside

@ark0f ark0f added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Jul 5, 2022
@saethlin
Copy link
Member

saethlin commented Jul 5, 2022

I'm confused, what do you think the difference is? Those mean the same thing to me.

@asquared31415
Copy link
Contributor

Those do mean the same thing, because "dropping excess capacity" is reallocating, which means moving to a new allocation. However this probably could be clarified/made consistent anyway. I don't see why these shouldn't be identical docs.

@HintringerFabian
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants