Any reason to upgrade --edition 2021?

I currently use 2021 crate format. Is there any reason to upgrade to a newer version?

Let chains are only available on edition 2024+.

More generally, your code will be less idiomatic and intuitive to others over time due edition differences like the RPIT capturing behavior. I'd suggest the latest possible edition (after considerations like the MSRV) for any new or actively maintained project.

3 Likes

Thanks, updated my scripts to 2024.

I second this. For new projects I always use the latest edition.
I also successively upgrade my existing projects to the latest edition if it does not result in too much code churn.

Migrating was painless for me, as simple as:

image

in my Cargo.toml. I must not know enough advanced language features to get code churn.. Haven't heard any horror stories of a 2024 migration either, unless you have one.

1 Like

The new precise lifetime capturing can introduce some issues in some cases.

I don't have any off-hand, but it's recommended to check and review ahead of time as not all edition gated changes have machine applicable suggestions, or SemVer compatible changes. (Edition 2024 changes include a couple such corner cases. In the extreme that could mean delaying the migration until a SemVer bump.)

((I did see some macro related issues go by on GitHub but didn't dig into them. I don't think they were horror stories really. There is a conscious effort to keep edition migration mostly smooth and to not fragment the ecosystem on edition boundaries.))

Sounds like expr_2021

Seems like it would be pretty unlikely to have breaking code from that and it would be pretty loud and easy to fix if so.

Mine looks similar:

1 Like

I think this is what I was remembering. Core fixed it on the new edition magically in a couple ways[1] that aren't available outside of core.

I believe that's this one. A few search attempts didn't reveal any similar issues to me though, so it's probably a rare scenario too.


  1. magic macro, super let â†Šī¸Ž

1 Like

Pretty bizarre code I can't imagine someone writing outside of a macro, yeah. Though I do like the sound of "super let" :grinning_face_with_smiling_eyes:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.