You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The if-let chains are getting very close to stabilization (they were stabilized but later reverted due to a bug). There are nearly 500 if_chain! usages in this repo alone, so converting them by hand might prove too error-prone. Plus, there are other projects using the same if_chain crate (5 million+ downloads).
I do not know if its possible to create a lint that uses an external crate (any suggestions or links?), but if so, I would think this would be useful to other code as well.
Lint Name
uses_if_chain_crate
Category
complexity
Advantage
keep the code simpler by using non-macro code
Drawbacks
cargo fmt still hasn't been decided (see rfc) on how to handle it, and doesn't seem likely to be decided soon. This is not a blocker, as the code can always be reformatted later. Also, the current macro code is not supported by fmt either, so there is no difference in this regard.
Note that it's not a 1:1 transition if you want to avoid warnings from the rust compiler. If there are suggestions, they should suggest moving any irrefutable patterns that the chain starts with outside of the chain, and any irrefutable pattern that the chain ends with into the body. Because otherwise there would be a lint as per rust-lang/rust#94951 .
What it does
The if-let chains are getting very close to stabilization (they were stabilized but later reverted due to a bug). There are nearly 500 if_chain! usages in this repo alone, so converting them by hand might prove too error-prone. Plus, there are other projects using the same if_chain crate (5 million+ downloads).
I do not know if its possible to create a lint that uses an external crate (any suggestions or links?), but if so, I would think this would be useful to other code as well.
Lint Name
uses_if_chain_crate
Category
complexity
Advantage
keep the code simpler by using non-macro code
Drawbacks
cargo fmt
still hasn't been decided (see rfc) on how to handle it, and doesn't seem likely to be decided soon. This is not a blocker, as the code can always be reformatted later. Also, the current macro code is not supported byfmt
either, so there is no difference in this regard.Example
Could be written as:
The text was updated successfully, but these errors were encountered: