weihanglo / rust-algorithm-club

Learn algorithms and data structures with Rust
https://weihanglo.tw/rust-algorithm-club
MIT License
407 stars 43 forks source link

Make get/get_mut/remove in HashMap more flexible with Borrow trait #12

Closed choznerol closed 6 years ago

choznerol commented 6 years ago

I noticed the TODO message along with the helpful hints in the HashMap implementation:

https://github.com/weihanglo/rust-algorithm-club/blob/188bb59ee0808dd0da4632eccf3b1cce192ed2be/src/collections/hash_map/mod.rs#L61-L86

if it's not currently under development, I would love to give it a try!

choznerol commented 6 years ago

The test in HashMap are all using this type Map ... in which K and V are set;

https://github.com/weihanglo/rust-algorithm-club/blob/188bb59ee0808dd0da4632eccf3b1cce192ed2be/src/collections/hash_map/mod.rs#L251

while in SinglyLinkedList, tests define the generic type one by one

https://github.com/weihanglo/rust-algorithm-club/blob/188bb59ee0808dd0da4632eccf3b1cce192ed2be/src/collections/singly_linked_list/mod.rs#L296

by completing this TODO, somewhere I'll need to add, for example HashMap<String, String>. Should I just follow the style in SinglyLinkList and update the tests in HashMap, or maybe there are some preferred testing style ?

weihanglo commented 6 years ago

@choznerol

Yeah, you're welcome to take the borrow trait task.

As for the testing style, my preference is no preference. Anything making code more clearer is acceptable. If there is some room to improve, just go for it!