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

docs for extend_from_slice say extend isnt specialized for slice yet #53185

Open
bjorn3 opened this issue Aug 8, 2018 · 12 comments
Open

docs for extend_from_slice say extend isnt specialized for slice yet #53185

bjorn3 opened this issue Aug 8, 2018 · 12 comments
Labels
A-collections Area: std::collections. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Aug 8, 2018

Noticed an error in the docs of Vec::extend_from_slice:

Note that this function is same as extend except that it is specialized to work with slices instead. If and when Rust gets specialization this function will likely be deprecated (but still available).

extend is already specialized for slices

@estebank estebank added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Aug 10, 2018
@frewsxcv
Copy link
Member

@rust-lang/libs Are there plans to deprecate extend_from_slice in favor of extend, or can we just remove this comment altogether?

@SimonSapin
Copy link
Contributor

If I remember correctly, the plan is to start "publicly" taking advantage of specialization in the standard library (even if indirectly, such as by recommending extend over extend_from_slice) after specialization is stable in the language, because of uncertainty around what eventually will or will not be allowed by specialization.

@alexcrichton
Copy link
Member

Yes until specialization is stable we do not want to deprecate this method.

@steveklabnik steveklabnik added the P-low Low priority label Dec 27, 2018
@steveklabnik
Copy link
Member

Seems like this is blocked on specialization, so tagging with low priority.

@briansmith
Copy link
Contributor

On the other hand, the documentation for Extend<&'a T> says that it is specialized for slice iterators, and it is pretty important that it is; otherwise we'd need extend_from_slice to be generalized into a trait.

@jonas-schievink jonas-schievink added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Dec 8, 2019
@jonas-schievink jonas-schievink added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-collections Area: std::collections. labels Mar 6, 2020
@Icelk
Copy link

Icelk commented Feb 13, 2021

Any news on this? Should I make a pull request depreciating the method or tweak the docs?

@thomcc
Copy link
Member

thomcc commented Feb 14, 2021

Seems like it's still blocked on specialization stabilizing...

@Icelk
Copy link

Icelk commented Feb 14, 2021

But I can’t help but notice the function (in the alloc source) turns the slice to an iterator an passes it to extend()
extend_from_slice is then an middlehand

@thomcc
Copy link
Member

thomcc commented Feb 14, 2021

Yes, that's already been discussed.

@Icelk
Copy link

Icelk commented Feb 14, 2021

So the function exists only if specialisation would disappear for slice iterators in the future?
Are there any updates on specialisation in the last two years?

@thomcc
Copy link
Member

thomcc commented Feb 14, 2021

Yes: #31844

It's also possible it will go the same route as const generics with a min_specialization (which already exists) stabilizing first. But it might not too, and might need to wait for Chalk to be integrated into the compiler more fully.

@Icelk
Copy link

Icelk commented Feb 15, 2021

Okay.
The function docs suggest it’s not specialised, as the issue author points out, but seeing as it turns it into an iterator, the docs are miss-leading. Should we change them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: std::collections. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants