top | item 34540747

(no title)

bdickason | 3 years ago

I recently spun up a project in Rust (a small game using Bevy) and the main issues I ran into were around smart defaults for the compiler. I was surprised how many lines I had to add to my cargo.toml to just complete a simple game example.

Some examples:

It defaulted to the fully backwards compatible version (vs 2021) which threw errors as I went through some recent example code.

(I think) I had to add a few lines to my cargo.toml so the compiler would not rebuild bevy every time I recompiled (when I only changed 1 line in my program).

discuss

order

TheDong|3 years ago

> It defaulted to the fully backwards compatible version (vs 2021)

"cargo init" and "cargo new" default to the 2021 edition, and have ever since it was stabilized: https://github.com/rust-lang/cargo/pull/9800

Either you accidentally installed a version of cargo from before the 2021 edition was stabilized, or you ran "cargo new --edition <something>", or you started by cloning an out of date project of some sort, in which case it's not really an issue with "defaults".

> smart defaults for the compiler. I was surprised how many lines I had to add to my cargo.toml

Normally this would be a pointlessly pedantic point, but cargo is not the compiler. This thread, the linked title blog post, they are about the rust compiler, not cargo. There's a close relationship, but cargo's defaults aren't necessarily related to what the "next rust compiler" might do.

bdickason|3 years ago

Thanks this is helpful!

I started my project without cargo at first and tried to start writing code without a cargo.toml. I was surprised that cairo didn't default to 2021 until I specified it in the .toml file. Good point that cargo init/new would have solved this!

I guess my point about the compiler was that it seems to rely on cargo.toml for many 'optimizations' that I would expect to be defaults. (Examples include the two i mentioned above).

But I'm new to the language and understand that most people will just use `cargo init` and google a few other common cargo.toml settings to improve compile times.