Skip to content

Commit 2d600a6

Browse files
committed
Merge remote-tracking branch 'origin' into docs
1 parent 612d506 commit 2d600a6

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

docs/docs/cargo-crates-and-basic-project-structure/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
│ └── simple_bench.rs
2828
└── examples
2929
└── simple_example.rs
30-
</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&rsquo;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>
31-
</span></span><span class=line><span class=cl><span class=nx>name</span> <span class=p>=</span> <span class=s2>&#34;api&#34;</span>
30+
</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&rsquo;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>Rust guarantees backward compatibility while introducing major updates to the language. To support this, the <code>edition</code> field was added to the <code>Cargo.toml</code> file in Rust 2018, marking the first major update to the language ecosystem three years after its initial release. Editions are opt-in, meaning existing crates will not experience 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 = "2024"</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>
31+
</span></span><span class=line><span class=cl><span class=nx>name</span> <span class=p>=</span> <span class=s2>&#34;hello_world&#34;</span>
3232
</span></span><span class=line><span class=cl><span class=nx>version</span> <span class=p>=</span> <span class=s2>&#34;0.1.0&#34;</span>
33-
</span></span><span class=line><span class=cl><span class=nx>edition</span> <span class=p>=</span> <span class=s2>&#34;2021&#34;</span>
34-
</span></span></code></pre></div><h2 id=-before-going-to-the-next>👨‍🏫 Before going to the next&mldr;</h2><ul><li><p>The <code>.cargo/bin</code> directory of your home directory is the default location of Rust binaries. Not only the official binaries like <code>rustc</code>, <code>cargo</code>, <code>rustup</code>, <code>rustfmt</code>, <code>rustdoc</code>, <code>rust-analyzer</code> and also the binaries you can install via <code>cargo install</code> command, will be stored in this directory.</p></li><li><p>Even though the initial convention for naming crates and file names is using the <a href=https://en.wikipedia.org/wiki/Snake_case target=_blank><code>snake_case</code></a>, some crate developers are using <code>kebab-case</code> on both crates and file names. To make your code more consistent, use the initial convention <code>snake_case</code>; especially on file names.</p></li><li><p>Create an executable crate via <code>cargo new</code> command and run it via <code>cargo run</code>.</p></li><li><p>Create a library crate via <code>cargo new</code> command and run <code>cargo test</code>.</p></li></ul></div><footer><time datetime=2024-03-10><i>🕒</i> Updated: 2024-03-10</time>
33+
</span></span><span class=line><span class=cl><span class=nx>edition</span> <span class=p>=</span> <span class=s2>&#34;2024&#34;</span>
34+
</span></span></code></pre></div><h2 id=-before-going-to-the-next>👨‍🏫 Before going to the next&mldr;</h2><ul><li><p>The <code>.cargo/bin</code> directory of your home directory is the default location of Rust binaries. Not only the official binaries like <code>rustc</code>, <code>cargo</code>, <code>rustup</code>, <code>rustfmt</code>, <code>rustdoc</code>, <code>rust-analyzer</code> and also the binaries you can install via <code>cargo install</code> command, will be stored in this directory.</p></li><li><p>Even though the initial convention for naming crates and file names is using the <a href=https://en.wikipedia.org/wiki/Snake_case target=_blank><code>snake_case</code></a>, some crate developers are using <code>kebab-case</code> on both crates and file names. To make your code more consistent, use the initial convention <code>snake_case</code>; especially on file names.</p></li><li><p>Create an executable crate via <code>cargo new</code> command and run it via <code>cargo run</code>.</p></li><li><p>Create a library crate via <code>cargo new</code> command and run <code>cargo test</code>.</p></li></ul></div><footer><time datetime=2025-03-13><i>🕒</i> Updated: 2025-03-13</time>
3535
<a href=https://learning-rust.github.io/docs/hello-world/><i></i> Previous</a>
3636
<a href=https://learning-rust.github.io/docs/comments-and-documenting-the-code/>Next <i></i></a></footer></article><aside><div><button class=btn><i></i>Close</button></div><strong>On this page</strong><nav id=TableOfContents><ul><li><a href=#cargo>Cargo</a></li><li><a href=#crate>Crate</a></li><li><a href=#project-structure>Project Structure</a></li><li><a href=#rust-editions>Rust Editions</a></li><li><a href=#-before-going-to-the-next>👨‍🏫 Before going to the next&mldr;</a></li></ul></nav></aside></main><footer><div><i>🧑‍💻</i>Built by and copyright<a href=https://github.com/dumindu target=_blank>Dumindu Madunuwan</a><i>📅</i> 2016-2025<i>🚀</i> <a href=https://github.com/learning-rust target=_blank>GitHub</a></div><div><button class=btn><i>☀️</i><i></i><i>🌑</i></button></div></footer></div></div><div id=body-model-outer></div><script type=text/javascript src=/assets/js/docs.min.12ffdc25c0149ef34e761ee54587f2aae17affcb8375298ad2180851930cb142.js integrity></script></body></html>

docs/docs/index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,5 +499,5 @@ For above cases, we can use &lt;code>panic!&lt;/code> macro.&lt;/li>
499499
&lt;p>⭐️ Rust is a &lt;strong>statically typed&lt;/strong> language; it checks data types at compile-time. But it &lt;strong>doesn’t require you to actually type it when declaring variable bindings&lt;/strong>. In that case, the compiler checks the usage and sets a better data type for it. But for &lt;strong>constants and statics, you must annotate the type&lt;/strong>. Types come after a colon(&lt;code>:&lt;/code>).&lt;/p></description></item><item><title>Vectors</title><link>https://learning-rust.github.io/docs/vectors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/vectors/</guid><description>&lt;p>If you remember, the array is a fixed-size list of elements, of the same data type. Even with mut, its element count cannot be changed. A vector is kind of &lt;strong>a re-sizable array&lt;/strong> but &lt;strong>all elements must be in the same type&lt;/strong>.&lt;/p>
500500
&lt;p>⭐️ It’s a generic type, written as &lt;strong>&lt;code>Vec&amp;lt;T&amp;gt;&lt;/code>&lt;/strong> . T can have any type, ex. The type of a Vec of i32s is &lt;code>Vec&amp;lt;i32&amp;gt;&lt;/code>. Also, Vectors always allocate their data in a dynamically allocated heap.&lt;/p></description></item><item><title>Why Rust?</title><link>https://learning-rust.github.io/docs/why-rust/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/why-rust/</guid><description>&lt;h2 id="history-of-rust">History of Rust&lt;/h2>
501501
&lt;p>Rust was initially designed and developed by former Mozilla employee &lt;strong>&lt;a href="https://github.com/graydon" target="_blank" >Graydon Hoare&lt;/a>&lt;/strong> as a personal project. Mozilla began sponsoring the project in 2009 and announced it in 2010. But the first stable release, Rust 1.0, was released on May 15, 2015.&lt;/p>
502-
&lt;p>Since Rust 1.0, major updates have been released as &lt;a href="https://doc.rust-lang.org/stable/edition-guide/editions/" target="_blank" >&lt;code>Editions&lt;/code>&lt;/a> approximately every three years: Rust 2015 (with the release of Rust 1.0) , Rust 2018, Rust 2021, and Rust 2024, all maintaining backward compatibility.&lt;/p></description></item><item><title>Workspaces</title><link>https://learning-rust.github.io/docs/workspaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/workspaces/</guid><description>&lt;p>When the code base is getting larger, you might need to work with &lt;strong>multiple crates on the same project&lt;/strong>. Rust supports this via Workspaces. You can &lt;strong>analyze (&lt;code>cargo check&lt;/code>), build, run tests or generate docs for all crates&lt;/strong> at once by running &lt;code>cargo&lt;/code> commands from the project root.&lt;/p>
502+
&lt;p>Since Rust 1.0, major updates have been released as &lt;a href="https://learning-rust.github.io/docs/cargo-crates-and-basic-project-structure/#rust-editions" >&lt;code>Editions&lt;/code>&lt;/a> approximately every three years: Rust 2015 (with the release of Rust 1.0) , Rust 2018, Rust 2021, and Rust 2024, all maintaining backward compatibility.&lt;/p></description></item><item><title>Workspaces</title><link>https://learning-rust.github.io/docs/workspaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/workspaces/</guid><description>&lt;p>When the code base is getting larger, you might need to work with &lt;strong>multiple crates on the same project&lt;/strong>. Rust supports this via Workspaces. You can &lt;strong>analyze (&lt;code>cargo check&lt;/code>), build, run tests or generate docs for all crates&lt;/strong> at once by running &lt;code>cargo&lt;/code> commands from the project root.&lt;/p>
503503
&lt;p>⭐️ When working on multiple crates same time, there is a higher possibility of having shared dependencies on crates. To prevent downloading and compiling the same dependency multiple times, Rust uses a &lt;strong>shared build directory&lt;/strong> under the project root, while running &lt;code>cargo build&lt;/code> from the project root.&lt;/p></description></item></channel></rss>

0 commit comments

Comments
 (0)