-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
slice::contains with borrowed data #62367
Comments
I'm fairly certain that this was essentially just a mistake when we implemented it, but we can't change it now as it causes inference failures across the ecosystem. I believe it's been tried multiple times and crater runs are disappointing. It's possible the inference for U: PartialEq or the reverse would also be worse. |
I feared that might be the case. :/ Would it be reasonable to add a |
Probably not worth it -- if you want to skip allocating |
Looking at the At the least, the docs should call out this alternative then. |
Hm, yeah, that might be slower for some cases. I forgot we had specialization internally to optimize for some types. Ideally we'd get around the inference failures somehow, e.g., with a default type param, but that seems unlikely to happen soon :/ |
explain how to search in slice without owned data Cc rust-lang#62367
explain how to search in slice without owned data Cc rust-lang#62367
HashSet::contains
has the following type to allow e.g. searching in aHashSet<String>
with an&str
:However,
slice::contains
does not useBorrow
, so to search in an&[String]
one has to actually allocate aString
:Is there a fundamental reason for this, or is this just an omission?
The text was updated successfully, but these errors were encountered: