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

Could we generate Borrow implementations to super classes? #3794

Open
madsmtm opened this issue Jan 18, 2024 · 1 comment
Open

Could we generate Borrow implementations to super classes? #3794

madsmtm opened this issue Jan 18, 2024 · 1 comment
Labels

Comments

@madsmtm
Copy link

madsmtm commented Jan 18, 2024

Summary

Borrow acts similarly to AsRef, with a slight difference being that the former also requires PartialEq, Eq and Hash to work the same for the borrowed type.

This seems to be upheld by JS classes -> superclasses, and as such I'm wondering why this trait isn't implemented for those?

Is it just because most of them don't implement Hash? If that were to change, would it make sense to implement Borrow?

Additional Details

I'm taking inspiration from this crate for a few design decisions for objc2, and would like to know your thoughts on this.

@daxpedda
Copy link
Collaborator

This seems to be upheld by JS classes -> superclasses, and as such I'm wondering why this trait isn't implemented for those?

I unfortunately don't know the historical context here, but I don't really see a reason why Borrow shouldn't be implemented.

Is it just because most of them don't implement Hash? If that were to change, would it make sense to implement Borrow?

I believe this isn't relevant. Borrow doesn't require Hash, it just requires Hash implementations to have the same output, which is irrelevant in our case as long as we don't implement Hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants