uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Allow foreign implementations of PartialEq, Eq, Hash etc traits

Open mgeisler opened this issue 1 year ago • 5 comments

From reading the manual and searching a bit, I don't think it's currently possible for my uniffi::Object and uniffi::Record types to expose their PartialEq, Eq, Hash, etc implementations?

Right now, I used a cheap workaround in my PR:

#[uniffi::export]
impl SigningIdentity {
    /// Is `self` equal to `other`?
    fn equals(&self, other: &Self) -> bool {
        self == other
    }
}

Ideally, the PartialEq impl would make it through. In Python, the __eq__ method could be wired up to delegate to PartialEq::eq, etc. The consequence of not having this is that things like assertions become more cumbersome.

Have I missed something in the manual about this?

mgeisler avatar Mar 20 '24 14:03 mgeisler