AsRef<str> is considered better style, I believe. A user could define a new type, implement
AsRef<str> for that type, and then pass the type to any function with an
An alternative is to implement
Deref<target=str> for the type, which would then allow the compiler to coerce a reference to the type into a reference to
str (which is the behavior you're using in the example provided). With this, you can pass a reference to your type to a function expecting a
&str, and things will work as expected.
Also, you're probably right about the question wording. I'll put up a PR to fix it.
If you feel strongly about it, open an RFC (unless there's already been an RFC. I just did a cursory look and didn't find one)!
Well, that title makes me sound all fancy. As always, working on the FAQ is great.