Does exist crate with a hashmap as a trait without bound to a concrete implementation of a trait?
What kind of functionality do you need from this trait? Would the Index + IndexMut
suffice, for example?
1 Like
What about all? Or as much as possible. Rust's bug does not let me use struct. But my code could probably work with a trait instead of a struct.
I will try Index + IndexMut
. Thanks.
Very unlikely, since:
- a trait which is implemented only by one type is almost always redundant;
- a trait which will be implemented for at least both
HashMap
andBTreeMap
will inevitably miss some functionality (e.g. everything which uses the ordering guarantees of the latter).
Could you share an example of problematic code? There might be another workaround.
3 Likes
By the way, it seems HashMap
does not implement IndexMut
.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.