-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat(types): impl PartialEq
and Hash
for Ident
instead of ModulePath
#108
Conversation
…lePath` This follows the original implementation. 2 `Ident`s should be equal if their values are equal, even if their `Span`s are different. This also includes manually implementing `Hash` to allow for this.
src/parser/types.rs
Outdated
impl Hash for Ident { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.value.hash(state); | ||
self.span.hash(state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the TODO was explicitly about not having the span in the hash :o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw I think this solution would be cleaner: https://users.rust-lang.org/t/rust-crate-for-ignore-this-field-for-eq-partialeq-hash/33651/6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I see, I misunderstood the intention. I can fix it in this PR (or restore the TODO if that's preferable).
I think the derivative
crate is unmaintained and still uses syn v1, so that may not be a great idea. However an alternative (educe) was also presented in that issue, and that uses syn v2. We can bring that in, if this is preferable over manual implementation(s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome thanks a lot!
Extracted from #100
This follows the original implementation. 2
Ident
s should be equal if their values are equal, even if theirSpan
s are different. This also includes manually implementingHash
to allow for this.