-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strfmt doesn't work with literal strings as keys #38
Comments
It is a common situation. It's the exact situation that std::fmt already supports!
|
if you have static strings, then just do |
That only works if you have a literal string for the format. I didn't demonstrate this in my example, but the reason I'm trying to do this is because I want to have the format string reside in a constant in a different module. |
Yes, that use-case isn't supported by this library. In theory I suppose it could support |
I might be doing something wrong, but it appears that
strfmt
doesn't accept aHashMap
with keys that are string literals (i.e.&'static str
). This seems weird to me, as this seems like a common situation.I would naively expect the following to work:
But it fails to compile, with the following error:
One fix is to explicit convert the string literals to
String
:This seems kinda weird to me, because I would think this is a common use case and that there wouldn't be a need to add the boilerplate of string conversions.
The text was updated successfully, but these errors were encountered: