rust-lang / cfg-if

A if/elif-like macro for Rust #[cfg] statements
Apache License 2.0
557 stars 40 forks source link

Nested if #7

Closed peng1999 closed 5 years ago

peng1999 commented 6 years ago

This implements issue #6 . Original code are not touched, and just the original cfg_if is renamed to __flat_cfg_if. The new cfg_if macro is a wrapper over it, using the TT builder to handle nested if.

alexcrichton commented 6 years ago

Thanks for the PR!

I'm a little wary to do this though as I unfortunately can't really understand the macro any more at this point :(. Would it be possible to have a simpler implementation which perhaps doesn't have as many bells-and-whistles but still gets the job done?

peng1999 commented 6 years ago

AFIK if-statement with an unconditional fallback can be handled more simply, but it is impossible to match a if-statement without unconditional fallback using a repetition matcher.

But my current solution is just a straightforward implementation of a incremental TT munchers, and I will add a detailed comment later. Will that help?

peng1999 commented 6 years ago

Comments added.

Aaron1011 commented 5 years ago

Is this PR still active? This would be a very useful feature to have

alexcrichton commented 5 years ago

Ah sorry for the... very long delay here. I don't think I'm personally interested in maintaining this in this repository, so I'm going to close this.

kupiakos commented 2 years ago

This continues to be a very useful feature to have. Would you reconsider maintaining this?