-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow identifiers to take arguments #5
Comments
The initial implementation will support the 3 default braces |
Update to the syntax: #[duplicate(
let_var( var_name ); [ let var_name = Default::default();]
)]
fn func(){
let_var([some_name]);
let_var([some_other_name]);
} Arguments given to a substitution identifier must be wrapped in any kind of braces. This distinguishes one argument from the other. #[duplicate(
let_var( var_name method); [ let var_name = MyTrait::method();]
)]
fn func(){
let_var([some_name] [some_method]);
let_var([some_other_name] [some_other_method]);
} Which expands to:
Notice in the declaration of the identifier, the argument list is not separated by anything, just a list of identifiers. |
Update to the identifier argument invocation:
When invoking a substitution identifer, the arguments must be separated by commas. This because rust will refuse to compile a list of groups (i.e. For now, the declaration of the identifier doesn't need commas. However, this may change in the future with a revision of the syntax. |
When declaring a substitution without arguments, they should be separated by commas. It's just confusing that you don't need a comma. Additionally, since all other rust code requires commas, it is muscle memory to add them, and causes confusion when |
Increase the flexibility of substitution by allowing identifiers to take "arguments" that change what is substituted.
Example:
Will expand to:
This issue will manage the feature for the short syntax only. A later issue will manage the same for the verbose syntax.
The text was updated successfully, but these errors were encountered: