The pros and cons of compiling via cargo or rustc ?
I have current rustc, cargo, rustup. when I create a toml file the edition is 2018. is that ok ?
The pros and cons of compiling via cargo or rustc ?
I have current rustc, cargo, rustup. when I create a toml file the edition is 2018. is that ok ?
You should use Cargo to build your Rust projects. You can call rustc directly for simple projects with no dependencies, but it's more straightforward to always use Cargo.
Yes, edition 2018 is the current edition and is what you should be using for new code. Very soon edition 2021 will be released, and at that point you can change that line in Cargo.toml
to read edition = "2021"
.
how do you rustacians know when a new edition has been released?
do we have to download anything in relation to the new edition ?
Well, it happens infrequently—about every three years so far. Any upcoming editions will be announced on blog.rust-lang.org, among other places. Note that even when a new edition is released, Rust guarantees that crates using previous editions will keep compiling and can interoperate with crates using the new edition. So moving to a new edition is not a time-sensitive thing.
You just have to upgrade your toolchain with rustup update
.
See the Edition Guide for more detail on all this stuff.
so, you need to know what edition will cover whatever version is installed?
Whatever version of what?
rust.
Does that make sense? Generally when you're writing new code you should always put the most recent edition in Cargo.toml
, and then just run rustup update
regularly (maybe a couple times a month) so you're always using an up-to-date toolchain. If you do that then you'll be good to go as far as your own (locally-developed) crates are concerned, and you don't have to worry about what editions other people's crates use.
**yeah, thats what i was getting at. **
so, just keep an eye out for new versions of rust, new editions, add the edition to the toml file, and update rustup
Is there a downside to staying up to date with everything?
backward compatibility could be a issue
Rust generally guarantees that code that works with one version of the compiler will continue to work with all future versions. The exceptions to this are:
Overall, Rust takes backward compatibility very seriously and tries to break it only in rare and extremely well-justified situations; it's one of the guiding principles of the whole project.
(This all assumes you're using the stable channel. If you use the beta or nightly channel then breaking changes will happen more regularly.)
stable channel, you mean for the rust version ?
The stable channel means you get each new Rust version as it's released. On the beta channel, you get a new Rust version when the previous version is released, so six weeks in advance. On the nightly channel, you get whatever's in the master branch of the Rust repository, updated every day-ish. More on the channels and the release model.
If you installed everything the normal way with rustup, you are on the stable channel by default.
ok. i think i am clear on the things that were on my mind:
use cargo to compile, wait for the new edition and then update toml, use rustup to keep rustc and cargo updated, put /target folder in a .gitignore file.
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.