I've been trying, although admittedly not with a lot of effort, to keep the edition
in my crates as old as possible. My reasoning has been to "maximize compatibility" [as long as it doesn't come at the cost of missing out on features]. I used to think this was generally the idea behind editions.
However, cargo new
defaults to the latest edition, which makes me think that the Crab Elders™️ want us to stick with the latest editions unless there's a compelling reason not to.
As far as I know, when compilation reaches down to MIR any "editioness" is erased, so there's no codegen-level reason to stick to the latest edition.
So what are the arguments for sticking with the oldest possible (i.e. without sacrificing features one wants/needs) edition? I read someone argue that there are rust developers who use their system's native package manager to install rust, and if one uses RedHat/Debian stable, this could mean sticking with very, very, old versions, and forcing later editions in crates could be an issue for such developers. But .. does this actually happen in practice?
I want to emphasize that I'm not talking about skipping useful features for the sake of being backwards compatible -- I'm specifically talking about cases where the switching between edition = 2018
and 2021
makes no difference, because the source code does not use any post-2018 features. What I'm starting to think is that a reason to choose the latter is to make it clear to contributors that they do not need to worry about backward compatibility.
I took a peek at some of the common crates I use (some of which are high up on the most downloaded list), and there's a mix of being edition = "2021"
, 2018
and not specifying edition at all.
It seems some projects omit the edition
and specify rust-version
instead. This seems compelling to me (because of the finer granularity), except for the fact that it can be sort-of a pain to determine the exact MSRV. (Has someone developed a binary search tool to empirically find out what the minimum supported version is?).
Should I keep striving for "oldest possible edition" or should I just stick with the latest one possible? And is the effort to find out the rust-version
worth it?