Skip to content
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

Add inline version of duplicate #6

Closed
Emoun opened this issue May 11, 2020 · 2 comments
Closed

Add inline version of duplicate #6

Emoun opened this issue May 11, 2020 · 2 comments
Labels
D-accepted A decision (D) has been made and the issue will be worked on I-feature This issue (I) regards a (potential) feature in the project T-accepted Triage (T): Initial review accepted issue/PR as valid

Comments

@Emoun
Copy link
Owner

Emoun commented May 11, 2020

Introduce a function-like procedural macro with the same functionality as duplicate.

duplicate can only be used where attributes are allowed. Notably, attributes are currently not allowed on statements. This is a significant limitation. Therefore, we can alleviate this by introducing a function-like version of duplicate that can be used where the original is not allowed.

Example:

fn main() {
  duplicate_inline!{
    #[
      name    value; 
      [var1]  [1usize]; 
      [var2]  [2usize]; 
      [var3]  [2usize]
    ]
    let name = value;
  }
}

Expands to:

fn main() {
    let var1 = 1usize;
    let var2 = 2usize;
    let var3 = 3usize;
}
@Emoun Emoun added D-discussion A decision (D) has not been made yet and is open to discussion I-feature This issue (I) regards a (potential) feature in the project T-accepted Triage (T): Initial review accepted issue/PR as valid labels May 11, 2020
@Emoun Emoun added D-accepted A decision (D) has been made and the issue will be worked on and removed D-discussion A decision (D) has not been made yet and is open to discussion labels Jul 7, 2020
@Emoun
Copy link
Owner Author

Emoun commented Aug 10, 2020

Initial implementation done. Though the syntax doesn't use a # before the invocation block.

@Emoun
Copy link
Owner Author

Emoun commented Aug 10, 2020

Release as part of v0.2.7

@Emoun Emoun closed this as completed Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-accepted A decision (D) has been made and the issue will be worked on I-feature This issue (I) regards a (potential) feature in the project T-accepted Triage (T): Initial review accepted issue/PR as valid
Projects
None yet
Development

No branches or pull requests

1 participant