Equivalent trait to pass custom "borrowed" structs as key
#405
PoOnesNerfect
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Have you thought about introducing
Equivalenttrait, which you can implement for struct, so that you can create a customborrowedstruct for key?For example, currently, if you want have a struct as a key:
To get a value from a cache, you have to own the key then reference it. So, if you don't own the key fields, you must clone to get the cache.
However, by using
Equivalenttrait, you can create a custom borrowed struct:This way, you don't have to own all the values in the key in order to fetch the value.
I have a fork that I've been using for this exact purpose: thuo-io#1
If you think this could be a good addition to the library, I can open a PR; or it's totally fine to not want to have this change.
p.s. the trait itself is a copy from another popular hashmap library, I forget where since it's been so long that i've copied it.
Beta Was this translation helpful? Give feedback.
All reactions