-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
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()
.
killercup, cramertj, kennytm, zackmdavis, bluss and 21 more
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.