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

Feature: Repeat index in macros #21908

Closed
Centril opened this issue Feb 3, 2015 · 2 comments
Closed

Feature: Repeat index in macros #21908

Centril opened this issue Feb 3, 2015 · 2 comments

Comments

@Centril
Copy link
Contributor

Centril commented Feb 3, 2015

It would be really swell if you could somehow access the index or depth of the current repeat in a macro.

Say if we are repeating with $($x), then $#x would yield the index of the current $x in the sequence.

The $# is really not important, could be anything else really.

For example:

#[macro_export]
macro_rules! letmany {
    ($($x:ident),+) => {
        let $x = $#x;
    };
}

fn main() {
    letmany!(a, b, c);
}

Would expand to:

fn main() {
    let a = 0;
    let b = 1;
    let c = 2;
}

Thoughts?

@lilyball
Copy link
Contributor

lilyball commented Feb 3, 2015

As mentioned on IRC, this has already been filed as #12782 and #12916, and in both cases the decision was that this has to go through the RFC process. I filed an RFC that covered this as rust-lang/rfcs#88, which has lots of discussion, and the ultimate decision was that this is a post-1.0 feature.

If you have any feedback on this, commenting on that RFC is probably the best bet, as that's likely to be the starting point for any further discussion of this post-1.0.

@Centril
Copy link
Contributor Author

Centril commented Feb 3, 2015

Thanks, I'll close this issue and comment on the RFC instead.

@Centril Centril closed this as completed Feb 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants