Skip to content

~"" == "" fails to borrow #3470

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

Closed
ghost opened this issue Sep 12, 2012 · 2 comments
Closed

~"" == "" fails to borrow #3470

ghost opened this issue Sep 12, 2012 · 2 comments
Assignees
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone

Comments

@ghost
Copy link

ghost commented Sep 12, 2012

If I use "Function eq - Bytewise string equality", only I put mutable and also there is limited type..

hmm.. Isn't here any good way to compare variables?

@graydon
Copy link
Contributor

graydon commented Sep 12, 2012

There are no mutable strings. If you mean "" and ~"", the comparison failing between them presently is a bug in type inference surrounding the == operator and will eventually be fixed. Or at least this is Niko's assessment. I'm assigning to him in the meantime but I expect this bug will solve itself. You can work around it using str::eq_slice() for now (which itself should be merged with str::eq). Apologies, the str module is still in transition from earlier work on it during the summer.

@nikomatsakis
Copy link
Contributor

I think this is working as designed. If you need to compare slices to unique strings, you want str::eq(), == is used for values of the same type. I originally thought we could make it otherwise but I now believe we cannot.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants