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

impl PartialEq<CompactStr> for &str #14

Closed
rusty-snake opened this issue Sep 22, 2021 · 1 comment · Fixed by #15
Closed

impl PartialEq<CompactStr> for &str #14

rusty-snake opened this issue Sep 22, 2021 · 1 comment · Fixed by #15

Comments

@rusty-snake
Copy link

Example that works:

use compact_str::CompactStr;
fn main() {
    dbg!(CompactStr::from("hello") == "hello");
}

Example that don't work:

use compact_str::CompactStr;
fn main() {
    dbg!("hello" == CompactStr::from("hello"));  
}

Error:

error[E0277]: can't compare `&str` with `CompactStr`
 --> src/main.rs:4:18
  |
4 |     dbg!("hello" == CompactStr::from("hello"));
  |                  ^^ no implementation for `&str == CompactStr`
  |
  = help: the trait `PartialEq<CompactStr>` is not implemented for `&str`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `test01` due to previous error

I think it shouldn't make any differences whether you want to compare &str with CompactStr, &str with &CompactStr, CompactStr with &str or &CompactStr with &str.

@ParkMyCar
Copy link
Owner

Thanks for submitting the issue! I figured there would be a couple missing impls like this, I'll try and get this fixed soon. If someone else would like to submit a PR though, feel free 🙂

nottirb pushed a commit to nottirb/compact_str that referenced this issue May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants