-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Cow from array #117342
Cow from array #117342
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
r? libs-api |
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.
Thanks for the PR!
Before I put this to FCP, would you be able to share some example code in which doing this conversion generically using From
is useful? Usually I'd expect what you showed to be written as:
Cow::Borrowed::<[i32]>(&[1, 1, 2, 3, 5, 8])
or:
Cow::Borrowed(&[1, 1, 2, 3, 5, 8] as &[i32])
Its supposed to fix I think its still useful though, if only because it saves you a rewrite when you do it (dont have to change it to Is |
I would say, yes, The impls exists in support of generic code like this: rust/compiler/rustc_errors/src/diagnostic.rs Lines 974 to 981 in 1dfb6b1
where they enable different callers to efficiently pass a variety of different types for the |
Wont this help, there, then? |
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
CC #113489 |
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.
Thanks zachs18! Closing in favor of #113489, as that one was opened earlier and demonstrated the use case.
enables
as well as
References #116890