-</code></pre><ul><li>The source code goes in the <code>src</code> directory.<ul><li>The default executable file is <code>src/main.rs</code>.</li><li>The default library file is <code>src/lib.rs</code>.</li><li>Other executables can be placed in,<ul><li><code>src/bin/*.rs</code></li><li><code>src/bin/*/main.rs</code></li></ul></li></ul></li><li>Integration tests go in the <code>tests</code> directory (unit tests go in each file they’re testing).</li><li>Benchmarks go in the <code>benches</code> directory.</li><li>Examples go in the <code>examples</code> directory.</li></ul><h2 id=rust-editions>Rust Editions</h2><p>The language has seen a series of improvements every three years through new editions since its initial stable release in 2015, including the initial version, <strong>Rust 2015</strong>, followed by <strong>Rust 2018</strong>, and the latest, <strong>Rust 2021</strong>.</p><p>The <code>edition</code> key in the <code>Cargo.toml</code> file denotes the edition of the Rust compiler to be used for compiling the crate. Editions are opt-in, meaning existing crates will not see these changes until they explicitly migrate to the new edition. Rust guarantees backward compatibility between editions, allowing crates using older editions of Rust to interoperate seamlessly with those using newer versions.</p><p>For new projects created by <code>cargo new</code>, it will set <code>edition = "2021"</code> by default in the <code>Cargo.toml</code> file. For example,</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-toml data-lang=toml><span class=line><span class=cl><span class=p>[</span><span class=nx>package</span><span class=p>]</span>
0 commit comments