-
Notifications
You must be signed in to change notification settings - Fork 98
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
Refactor FluentArgs for better ergonomics #123
Comments
From #120 (comment):
Can you explain why that is? I'd assume using slices to static strings in |
In real code you often work with programmatically generated arguments. Either directly, or passed from some external source. In such cases, having to pass For example, in Gecko I receive In result it's just one of those cases in Rust, where My intention in this PR will be to add some macro and maybe Cow, to make it look more like: fluent_args!(
"name": "John",
"emailCound": 5
); |
OK, I see, thanks for the explanation. In simple cases, the argument keys would be OK to stay as
Macros hide complexity, rather than remove it.
Do we need to be able to modify the argument names? |
Nope, but it would be nice to accept |
Hmm, but even with |
Yes.
That's another thing I'd like to provide a helper for.
Not really. What we should get to is a state where at least Quoting kornel from rust-lang/rust#46966 (comment)
|
For this item, I'd like to improve ergonomics of passing arguments to Currently, the What I think I'd like to get to is: a) What should be the type? I see This has been already discussed a bit in #94 and rust-lang/rust#46966 (comment) but I'm not sure what the correct approach is for us. (the keys only need to live long enough for the b) What kind of macro can we build to facilitate the args construction? I'm thinking of something similar to I thought of sth like: let args = fluent_args![
"name": "John",
"emailCount": 5
]; but preferably it should also allow for: let args = fluent_args![
"name": FluentValue::String("John"),
"emailCount": FluentValue::Number(5)
]; Do you have any thoughts on how to make it canonical for Rust integration and how to integrate it into (a)? |
Not really, this is weird enough that there's no obvious ergonomic way to do it that pops up. let args = fluent_args![
"name": "John",
"emailCount": 5
]; You can write a proc macro for the above, though. |
I'd like to oppose the addition of the |
The current PR places the macro in Would you be ok to put the macro there? I understand the low-level aim for |
Yes, I think that's a good compromise. Thanks for taking my input into account. |
Currently FluentArgs is a HashMap over
&str
(and I'm going to change it to overString
).It would be nice to have it over
Cow
maybe and write some helper/macro to construct args.The text was updated successfully, but these errors were encountered: