Skip to content

Instantly share code, notes, and snippets.

@kinnison
Last active May 30, 2019 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinnison/001c508c2b63e3e65cd719acdadfa2ed to your computer and use it in GitHub Desktop.
Save kinnison/001c508c2b63e3e65cd719acdadfa2ed to your computer and use it in GitHub Desktop.
A mechanism to think about hash and borrow implementations
// Related to a comment from @nrc regarding Hash<Ty> and Borrow<Ty> interactions...
// I wonder if a generic hash implementation of:
impl<Outer: Borrow<Inner>, Inner: Hash> Hash for Outer {
fn hash<H: Hasher>(self: &Outer, state: &mut H) {
self.borrow().hash(state);
}
}
// Might solve the issue? Or at least mean that there's a generic way to deal with it?
// Note, I have no idea if that would work or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment