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

Compare ArchivedString against Cow<'_, str> #421

Open
tv42 opened this issue Sep 6, 2023 · 1 comment
Open

Compare ArchivedString against Cow<'_, str> #421

tv42 opened this issue Sep 6, 2023 · 1 comment

Comments

@tv42
Copy link

tv42 commented Sep 6, 2023

I have

#[derive(rkyv::Serialize, rkyv::Archive, rkyv::Deserialize, Debug)]
#[archive(check_bytes)]
#[archive_attr(derive(Debug))]
pub struct Example {
    pub name: String,
}
struct Thing<'a> {
   x: Cow<'a, str>,
}

and fn lookup(&self, thing: &Thing) ...

What I wanted to do was archived_example.name == thing.x, but that doesn't compile:

error[E0277]: can't compare `ArchivedString` with `Cow<'_, str>`
  --> foo.rs:94:34
   |
94 |             if archived_example.name == thing.x
   |                                  ^^ no implementation for `ArchivedString == Cow<'_, str>`
   |
   = help: the trait `PartialEq<Cow<'_, str>>` is not implemented for `ArchivedString`
   = help: the following other types implement trait `PartialEq<Rhs>`:
             <ArchivedString as PartialEq>
             <ArchivedString as PartialEq<std::string::String>>
             <ArchivedString as PartialEq<str>>
             <ArchivedString as PartialEq<&str>>

Could ArchivedString also handle Cow, please?

Workaround: archived_example.name.as_str() == thing.x

@djkoloski
Copy link
Collaborator

May aggravate #434, I'm not opposed to an impl if it gets put behind extra_traits.

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

No branches or pull requests

2 participants