Closed
Description
The example in the docs uses HashMap
of &str
:
https://doc.rust-lang.org/std/collections/struct.HashMap.html#examples
but this gives bad example to users who copy the example without fully realizing consequences of using &str
instead of String
. Here's thread by a new user lead down a confusing path because of this example: https://users.rust-lang.org/t/how-to-pass-slice-of-structs-string-field/14586
I suggest using String
instead, even if that means a bit more noise from to_owned()
.