Here is the canonical way to learn Rust
None
2022-11-03
<div>
 
 
 
 
 
 
 
 
 <nav>
 <div>
 <ol><li><a href="title-page.html">The Rust Programming Language</a></li><li><a href="foreword.html">Foreword</a></li><li><a href="ch00-00-introduction.html">Introduction</a></li><li><a href="ch01-00-getting-started.html"><strong>1.</strong> Getting Started</a></li><li><ol><li><a href="ch01-01-installation.html"><strong>1.1.</strong> Installation</a></li><li><a href="ch01-02-hello-world.html"><strong>1.2.</strong> Hello, World!</a></li><li><a href="ch01-03-hello-cargo.html"><strong>1.3.</strong> Hello, Cargo!</a></li></ol></li><li><a href="ch02-00-guessing-game-tutorial.html"><strong>2.</strong> Programming a Guessing Game</a></li><li><a href="ch03-00-common-programming-concepts.html"><strong>3.</strong> Common Programming Concepts</a></li><li><ol><li><a href="ch03-01-variables-and-mutability.html"><strong>3.1.</strong> Variables and Mutability</a></li><li><a href="ch03-02-data-types.html"><strong>3.2.</strong> Data Types</a></li><li><a href="ch03-03-how-functions-work.html"><strong>3.3.</strong> Functions</a></li><li><a href="ch03-04-comments.html"><strong>3.4.</strong> Comments</a></li><li><a href="ch03-05-control-flow.html"><strong>3.5.</strong> Control Flow</a></li></ol></li><li><a href="ch04-00-understanding-ownership.html"><strong>4.</strong> Understanding Ownership</a></li><li><ol><li><a href="ch04-01-what-is-ownership.html"><strong>4.1.</strong> What is Ownership?</a></li><li><a href="ch04-02-references-and-borrowing.html"><strong>4.2.</strong> References and Borrowing</a></li><li><a href="ch04-03-slices.html"><strong>4.3.</strong> The Slice Type</a></li></ol></li><li><a href="ch05-00-structs.html"><strong>5.</strong> Using Structs to Structure Related Data</a></li><li><ol><li><a href="ch05-01-defining-structs.html"><strong>5.1.</strong> Defining and Instantiating Structs</a></li><li><a href="ch05-02-example-structs.html"><strong>5.2.</strong> An Example Program Using Structs</a></li><li><a href="ch05-03-method-syntax.html"><strong>5.3.</strong> Method Syntax</a></li></ol></li><li><a href="ch06-00-enums.html"><strong>6.</strong> Enums and Pattern Matching</a></li><li><ol><li><a href="ch06-01-defining-an-enum.html"><strong>6.1.</strong> Defining an Enum</a></li><li><a href="ch06-02-match.html"><strong>6.2.</strong> The match Control Flow Construct</a></li><li><a href="ch06-03-if-let.html"><strong>6.3.</strong> Concise Control Flow with if let</a></li></ol></li><li><a href="ch07-00-managing-growing-projects-with-packages-crates-and-modules.html"><strong>7.</strong> Managing Growing Projects with Packages, Crates, and Modules</a></li><li><ol><li><a href="ch07-01-packages-and-crates.html"><strong>7.1.</strong> Packages and Crates</a></li><li><a href="ch07-02-defining-modules-to-control-scope-and-privacy.html"><strong>7.2.</strong> Defining Modules to Control Scope and Privacy</a></li><li><a href="ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html"><strong>7.3.</strong> Paths for Referring to an Item in the Module Tree</a></li><li><a href="ch07-04-bringing-paths-into-scope-with-the-use-keyword.html"><strong>7.4.</strong> Bringing Paths Into Scope with the use Keyword</a></li><li><a href="ch07-05-separating-modules-into-different-files.html"><strong>7.5.</strong> Separating Modules into Different Files</a></li></ol></li><li><a href="ch08-00-common-collections.html"><strong>8.</strong> Common Collections</a></li><li><ol><li><a href="ch08-01-vectors.html"><strong>8.1.</strong> Storing Lists of Values with Vectors</a></li><li><a href="ch08-02-strings.html"><strong>8.2.</strong> Storing UTF-8 Encoded Text with Strings</a></li><li><a href="ch08-03-hash-maps.html"><strong>8.3.</strong> Storing Keys with Associated Values in Hash Maps</a></li></ol></li><li><a href="ch09-00-error-handling.html"><strong>9.</strong> Error Handling</a></li><li><ol><li><a href="ch09-01-unrecoverable-errors-with-panic.html"><strong>9.1.</strong> Unrecoverable Errors with panic!</a></li><li><a href="ch09-02-recoverable-errors-with-result.html"><strong>9.2.</strong> Recoverable Errors with Result</a></li><li><a href="ch09-03-to-panic-or-not-to-panic.html"><strong>9.3.</strong> To panic! or Not to panic!</a></li></ol></li><li><a href="ch10-00-generics.html"><strong>10.</strong> Generic Types, Traits, and Lifetimes</a></li><li><ol><li><a href="ch10-01-syntax.html"><strong>10.1.</strong> Generic Data Types</a></li><li><a href="ch10-02-traits.html"><strong>10.2.</strong> Traits: Defining Shared Behavior</a></li><li><a href="ch10-03-lifetime-syntax.html"><strong>10.3.</strong> Validating References with Lifetimes</a></li></ol></li><li><a href="ch11-00-testing.html"><strong>11.</strong> Writing Automated Tests</a></li><li><ol><li><a href="ch11-01-writing-tests.html"><strong>11.1.</strong> How to Write Tests</a></li><li><a href="ch11-02-running-tests.html"><strong>11.2.</strong> Controlling How Tests Are Run</a></li><li><a href="ch11-03-test-organization.html"><strong>11.3.</strong> Test Organization</a></li></ol></li><li><a href="ch12-00-an-io-project.html"><strong>12.</strong> An I/O Project: Building a Command Line Program</a></li><li><ol><li><a href="ch12-01-accepting-command-line-arguments.html"><strong>12.1.</strong> Accepting Command Line Arguments</a></li><li><a href="ch12-02-reading-a-file.html"><strong>12.2.</strong> Reading a File</a></li><li><a href="ch12-03-improving-error-handling-and-modularity.html"><strong>12.3.</strong> Refactoring to Improve Modularity and Error Handling</a></li><li><a href="ch12-04-testing-the-librarys-functionality.html"><strong>12.4.</strong> Developing the Libraryâs Functionality with Test Driven Development</a></li><li><a href="ch12-05-working-with-environment-variables.html"><strong>12.5.</strong> Working with Environment Variables</a></li><li><a href="ch12-06-writing-to-stderr-instead-of-stdout.html"><strong>12.6.</strong> Writing Error Messages to Standard Error Instead of Standard Output</a></li></ol></li><li><a href="ch13-00-functional-features.html"><strong>13.</strong> Functional Language Features: Iterators and Closures</a></li><li><ol><li><a href="ch13-01-closures.html"><strong>13.1.</strong> Closures: Anonymous Functions that Capture Their Environment</a></li><li><a href="ch13-02-iterators.html"><strong>13.2.</strong> Processing a Series of Items with Iterators</a></li><li><a href="ch13-03-improving-our-io-project.html"><strong>13.3.</strong> Improving Our I/O Project</a></li><li><a href="ch13-04-performance.html"><strong>13.4.</strong> Comparing Performance: Loops vs. Iterators</a></li></ol></li><li><a href="ch14-00-more-about-cargo.html"><strong>14.</strong> More about Cargo and Crates.io</a></li><li><ol><li><a href="ch14-01-release-profiles.html"><strong>14.1.</strong> Customizing Builds with Release Profiles</a></li><li><a href="ch14-02-publishing-to-crates-io.html"><strong>14.2.</strong> Publishing a Crate to Crates.io</a></li><li><a href="ch14-03-cargo-workspaces.html"><strong>14.3.</strong> Cargo Workspaces</a></li><li><a href="ch14-04-installing-binaries.html"><strong>14.4.</strong> Installing Binaries from Crates.io with cargo install</a></li><li><a href="ch14-05-extending-cargo.html"><strong>14.5.</strong> Extending Cargo with Custom Commands</a></li></ol></li><li><a href="ch15-00-smart-pointers.html"><strong>15.</strong> Smart Pointers</a></li><li><ol><li><a href="ch15-01-box.html"><strong>15.1.</strong> Using Box&lt;T&gt; to Point to Data on the Heap</a></li><li><a href="ch15-02-deref.html"><strong>15.2.</strong> Treating Smart Pointers Like Regular References with the Deref Trait</a></li><li><a href="ch15-03-drop.html"><strong>15.3.</strong> Running Code on Cleanup with the Drop Trait</a></li><li><a href="ch15-04-rc.html"><strong>15.4.</strong> Rc&lt;T&gt;, the Reference Counted Smart Pointer</a></li><li><a href="ch15-05-interior-mutability.html"><strong>15.5.</strong> RefCell&lt;T&gt; and the Interior Mutability Pattern</a></li><li><a href="ch15-06-reference-cycles.html"><strong>15.6.</strong> Reference Cycles Can Leak Memory</a></li></ol></li><li><a href="ch16-00-concurrency.html"><strong>16.</strong> Fearless Concurrency</a></li><li><ol><li><a href="ch16-01-threads.html"><strong>16.1.</strong> Using Threads to Run Code Simultaneously</a></li><li><a href="ch16-02-message-passing.html"><strong>16.2.</strong> Using Message Passing to Transfer Data Between Threads</a></li><li><a href="ch16-03-shared-state.html"><strong>16.3.</strong> Shared-State Concurrency</a></li><li><a href="ch16-04-extensible-concurrency-sync-and-send.html"><strong>16.4.</strong> Extensible Concurrency with the Sync and Send Traits</a></li></ol></li><li><a href="ch17-00-oop.html"><strong>17.</strong> Object Oriented Programming Features of Rust</a></li><li><ol><li><a href="ch17-01-what-is-oo.html"><strong>17.1.</strong> Characteristics of Object-Oriented Languages</a></li><li><a href="ch17-02-trait-objects.html"><strong>17.2.</strong> Using Trait Objects That Allow for Values of Different Types</a></li><li><a href="ch17-03-oo-design-patterns.html"><strong>17.3.</strong> Implementing an Object-Oriented Design Pattern</a></li></ol></li><li><a href="ch18-00-patterns.html"><strong>18.</strong> Patterns and Matching</a></li><li><ol><li><a href="ch18-01-all-the-places-for-patterns.html"><strong>18.1.</strong> All the Places Patterns Can Be Used</a></li><li><a href="ch18-02-refutability.html"><strong>18.2.</strong> Refutability: Whether a Pattern Might Fail to Match</a></li><li><a href="ch18-03-pattern-syntax.html"><strong>18.3.</strong> Pattern Syntax</a></li></ol></li><li><a href="ch19-00-advanced-features.html"><strong>19.</strong> Advanced Features</a></li><li><ol><li><a href="ch19-01-unsafe-rust.html"><strong>19.1.</strong> Unsafe Rust</a></li><li><a href="ch19-03-advanced-traits.html"><strong>19.2.</strong> Advanced Traits</a></li><li><a href="ch19-04-advanced-types.html"><strong>19.3.</strong> Advanced Types</a></li><li><a href="ch19-05-advanced-functions-and-closures.html"><strong>19.4.</strong> Advanced Functions and Closures</a></li><li><a href="ch19-06-macros.html"><strong>19.5.</strong> Macros</a></li></ol></li><li><a href="ch20-00-final-project-a-web-server.html"><strong>20.</strong> Final Project: Building a Multithreaded Web Server</a></li><li><ol><li><a href="ch20-01-single-threaded.html"><strong>20.1.</strong> Building a Single-Threaded Web Server</a></li><li><a href="ch20-02-multithreaded.html"><strong>20.2.</strong> Turning Our Single-Threaded Server into a Multithreaded Server</a></li><li><a href="ch20-03-graceful-shutdown-and-cleanup.html"><strong>20.3.</strong> Graceful Shutdown and Cleanup</a></li></ol></li><li><a href="appendix-00.html"><strong>21.</strong> Appendix</a></li><li><ol><li><a href="appendix-01-keywords.html"><strong>21.1.</strong> A - Keywords</a></li><li><a href="appendix-02-operators.html"><strong>21.2.</strong> B - Operators and Symbols</a></li><li><a href="appendix-03-derivable-traits.html"><strong>21.3.</strong> C - Derivable Traits</a></li><li><a href="appendix-04-useful-development-tools.html"><strong>21.4.</strong> D - Useful Development Tools</a></li><li><a href="appendix-05-editions.html"><strong>21.5.</strong> E - Editions</a></li><li><a href="appendix-06-translation.html"><strong>21.6.</strong> F - Translations of the Book</a></li><li><a href="appendix-07-nightly-rust.html"><strong>21.7.</strong> G - How Rust is Made and âNightly Rustâ</a></li></ol></li></ol>
 </div>
 
 </nav>
 <div>
 <div>
 
 <h2>The Rust Programming Language</h2>
 
 </div>
 <nav>
 <a href="foreword.html">
 <i></i>
 </a>
 </nav>
 </div>
 
 
 
 
 
 
 
 
 
 
||||I|||| 1. The Rust Programming Language
 2. Foreword
 3. Introduction
 4. 1. Getting Started
 5. 
 1. 1.1. Installation
 2. 1.2. Hello, World!
 3. 1.3. Hello, Cargo!
 6. 2. Programming a Guessing Game
 7. 3. Common Programming Concepts
 8. 
 1. 3.1. Variables and Mutability
 2. 3.2. Data Types
 3. 3.3. Functions
 4. 3.4. Comments
 5. 3.5. Control Flow
 9. 4. Understanding Ownership
 10. 
 1. 4.1. What is Ownership?
 2. 4.2. References and Borrowing
 3. 4.3. The Slice Type
 11. 5. Using Structs to Structure Related Data
 12. 
 1. 5.1. Defining and Instantiating Structs
 2. 5.2. An Example Program Using Structs
 3. 5.3. Method Syntax
 13. 6. Enums and Pattern Matching
 14. 
 1. 6.1. Defining an Enum
 2. 6.2. The match Control Flow Construct
 3. 6.3. Concise Control Flow with if let
 15. 7. Managing Growing Projects with Packages, Crates, and Modules
 16. 
 1. 7.1. Packages and Crates
 2. 7.2. Defining Modules to Control Scope and Privacy
 3. 7.3. Paths for Referring to an Item in the Module Tree
 4. 7.4. Bringing Paths Into Scope with the use Keyword
 5. 7.5. Separating Modules into Different Files
 17. 8. Common Collections
 18. 
 1. 8.1. Storing Lists of Values with Vectors
 2. 8.2. Storing UTF-8 Encoded Text with Strings
 3. 8.3. Storing Keys with Associated Values in Hash Maps
 19. 9. Error Handling
 20. 
 1. 9.1. Unrecoverable Errors with panic!
 2. 9.2. Recoverable Errors with Result
 3. 9.3. To panic! or Not to panic!
 21. 10. Generic Types, Traits, and Lifetimes
 22. 
 1. 10.1. Generic Data Types
 2. 10.2. Traits: Defining Shared Behavior
 3. 10.3. Validating References with Lifetimes
 23. 11. Writing Automated Tests
 24. 
 1. 11.1. How to Write Tests
 2. 11.2. Controlling How Tests Are Run
 3. 11.3. Test Organization
 25. 12. An I/O Project: Building a Command Line Program
 26. 
 1. 12.1. Accepting Command Line Arguments
 2. 12.2. Reading a File
 3. 12.3. Refactoring to Improve Modularity and Error Handling
 4. 12.4. Developing the Libraryâs Functionality with Test Driven Development
 5. 12.5. Working with Environment Variables
 6. 12.6. Writing Error Messages to Standard Error Instead of Standard Output
 27. 13. Functional Language Features: Iterators and Closures
 28. 
 1. 13.1. Closures: Anonymous Functions that Capture Their Environment
 2. 13.2. Processing a Series of Items with Iterators
 3. 13.3. Improving Our I/O Project
 4. 13.4. Comparing Performance: Loops vs. Iterators
 29. 14. More about Cargo and Crates.io
 30. 
 1. 14.1. Customizing Builds with Release Profiles
 2. 14.2. Publishing a Crate to Crates.io
 3. 14.3. Cargo Workspaces
 4. 14.4. Installing Binaries from Crates.io with cargo install
 5. 14.5. Extending Cargo with Custom Commands
 31. 15. Smart Pointers
 32. 
 1. 15.1. Using Box<T> to Point to Data on the Heap
 2. 15.2. Treating Smart Pointers Like Regular References with the Deref Trait
 3. 15.3. Running Code on Cleanup with the Drop Trait
 4. 15.4. Rc<T>, the Reference Counted Smart Pointer
 5. 15.5. RefCell<T> and the Interior Mutability Pattern
 6. 15.6. Reference Cycles Can Leak Memory
 33. 16. Fearless Concurrency
 34. 
 1. 16.1. Using Threads to Run Code Simultaneously
 2. 16.2. Using Message Passing to Transfer Data Between Threads
 3. 16.3. Shared-State Concurrency
 4. 16.4. Extensible Concurrency with the Sync and Send Traits
 35. 17. Object Oriented Programming Features of Rust
 36. 
 1. 17.1. Characteristics of Object-Oriented Languages
 2. 17.2. Using Trait Objects That Allow for Values of Different Types
 3. 17.3. Implementing an Object-Oriented Design Pattern
 37. 18. Patterns and Matching
 38. 
 1. 18.1. All the Places Patterns Can Be Used
 2. 18.2. Refutability: Whether a Pattern Might Fail to Match
 3. 18.3. Pattern Syntax
 39. 19. Advanced Features
 40. 
 1. 19.1. Unsafe Rust
 2. 19.2. Advanced Traits
 3. 19.3. Advanced Types
 4. 19.4. Advanced Functions and Closures
 5. 19.5. Macros
 41. 20. Final Project: Building a Multithreaded Web Server
 42. 
 1. 20.1. Building a Single-Threaded Web Server
 2. 20.2. Turning Our Single-Threaded Server into a Multithreaded Server
 3. 20.3. Graceful Shutdown and Cleanup
 43. 21. Appendix
 44. 
 1. 21.1. A - Keywords
 2. 21.2. B - Operators and Symbols
 3. 21.3. C - Derivable Traits
 4. 21.4. D - Useful Development Tools
 5. 21.5. E - Editions
 6. 21.6. F - Translations of the Book
 7. 21.7. G - How Rust is Made and âNightly Rustâ
 * Light (default)
 * Rust
 * Coal
 * Navy
 * Ayu

 The Rust Programming Language

 The Rust Programming Language

 by Steve Klabnik and Carol Nichols, with contributions from the Rust Community

 This version of the text assumes youâre using Rust 1.65 (released 2022-11-03) or later. See the âInstallationâ section of Chapter 1 to install or update Rust.

 The HTML format is available online at https://doc.rust-lang.org/stable/book/ and offline with installations of Rust made with rustup; run rustup docs --book to open.

 Several community translations are also available.

 This text is available in paperback and ebook format from No Starch Press.

 ð¨ Want a more interactive learning experience? Try out a different version of the Rust Book, featuring: quizzes, highlighting, visualizations, and more: https://rust-book.cs.brown.edu

The Rust Programming Language
https://doc.rust-lang.org/book/
None
2024-08-16T00:00:00Z
None
| view_count: 664,436 views | short_view_count: 664K views | num_likes: 15K | num_subscribers: 9.81 million
- YouTube
https://www.youtube.com/watch?v=BpPEoZW5IiY
None
2018-01-01T00:00:00-09:30
<div><div>
                    <a href="https://stevedonovan.github.io/rust-gentle-intro/readme.html#a-gentle-introduction-to-rust"></a>
<p></p>
<p><a href="http://leftoversalad.com/c/015_programmingpeople/">thanks to David Marino</a></p>
<a href="https://stevedonovan.github.io/rust-gentle-intro/readme.html#why-learn-a-new-programming-language"><h2>Why learn a new Programming Language?</h2></a>
<p>The aim of this tutorial is to take you to a place where you can read and write
enough Rust to fully appreciate the excellent learning resources available
online, in particular <a href="https://doc.rust-lang.org/stable/book/">The Book</a>.
It's an opportunity to <em>try before you buy</em>, and get enough feeling for the
power of the language to want to go deeper.</p>
<p>As Einstein might have said, "As gentle as possible, but no gentler.". There is a
lot of new stuff to learn here, and it's different enough to require some
rearrangement of your mental furniture. By 'gentle' I mean that the features are
presented practically with examples; as we encounter difficulties, I hope to
show how Rust solves these problems. It is important to understand the problems before
the solutions make sense. To put it in flowery language, we are going for a hike
in hilly country and I will point out some interesting rock formations on the way,
with only a few geology lectures. There will be some uphill but the view will be
inspiring; the community is unusually pleasant and happy to help.
There is the <a href="https://users.rust-lang.org/">Rust Users Forum</a> and an active
<a href="https://www.reddit.com/r/rust/">subreddit</a> which is unusually well-moderated.
The <a href="https://www.rust-lang.org/en-US/faq.html">FAQ</a> is a good resource if
you have specific questions.</p>
<p>First, why learn a new programming language? It is an investment of time and energy
and that needs some justification. Even if you do not immediately land
a cool job using that language, it stretches the mental muscles and makes you a
better programmer. That seems a poor kind of return-on-investment but if you're
not learning something <em>genuinely</em> new all the time then you will stagnate and be
like the person who has ten years of experience in doing the same thing over and over.</p>
<a href="https://stevedonovan.github.io/rust-gentle-intro/readme.html#where-rust-shines"><h2>Where Rust Shines</h2></a>
<p>Rust is a statically and strongly typed systems programming language. <em>statically</em>
means that all types are known at compile-time, <em>strongly</em> means that these types
are designed to make it harder to write incorrect programs. A successful compilation
means you have a much better guarantee of correctness than with a cowboy language
like C. <em>systems</em> means generating the best possible machine code with full control
of memory use.  So the uses are pretty hardcore: operating systems, device drivers
and embedded systems that might not even have an operating system.  However, it's
actually a very pleasant language to write normal application code in as well.</p>
<p>The big difference from C and C++ is that Rust is <em>safe by default</em>; all memory accesses
are checked. It is not possible to corrupt memory by accident.</p>
<p>The unifying principles behind Rust are:</p>
<ul>
<li>strictly enforcing <em>safe borrowing</em> of data</li>
<li>functions, methods and closures to operate on data</li>
<li>tuples, structs and enums to aggregate data</li>
<li>pattern matching to select and destructure data</li>
<li>traits to define <em>behaviour</em> on data</li>
</ul>
<p>There is a fast-growing ecosystem of available libraries through Cargo
but here we will concentrate on the core principles of the language
by learning to use the standard library. My advice is to write <em>lots of small programs</em>,
so learning to use <code>rustc</code> directly is a core skill. When doing the examples in this
tutorial I defined a little script called <code>rrun</code> which does a compilation and runs
the result:</p>
<pre><code>rustc $1.rs &amp;&amp; ./$1
</code></pre>
<a href="https://stevedonovan.github.io/rust-gentle-intro/readme.html#setting-up"><h2>Setting Up</h2></a>
<p>This tutorial assumes that you have Rust installed locally. Fortunately this is
<a href="https://www.rust-lang.org/en-US/downloads.html">very straightforward</a>.</p>
<pre><code>$ curl https://sh.rustup.rs -sSf | sh
$ rustup component add rust-docs
</code></pre>
<p>I would recommend getting the default stable version; it's easy to download
unstable versions later and to switch between.</p>
<p>This gets the compiler, the Cargo package manager, the API documentation, and the Rust Book.
The journey of a thousand miles starts with one step, and this first step is painless.</p>
<p><code>rustup</code> is the command you use to manage your Rust installation. When a new stable release
appears, you just have to say <code>rustup update</code> to upgrade. <code>rustup doc</code> will open
the offline documentation in your browser.</p>
<p>You will probably already have an editor you like, and <a href="https://areweideyet.com/">basic Rust support</a>
is good. I'd suggest you start out with basic syntax highlighting at first, and
work up as your programs get larger.</p>
<p>Personally I'm a fan of <a href="https://www.geany.org/Download/Releases">Geany</a> which is
one of the few editors with Rust support out-of-the-box; it's particularly easy
on Linux since it's available through the package manager, but it works fine on
other platforms.</p>
<p>The main thing is knowing how to edit, compile and run Rust programs.
You learn to program with your <em>fingers</em>; type in
the code yourself, and learn to rearrange things efficiently with your editor.</p>
<p>Zed Shaw's <a href="https://learnpythonthehardway.org/book/intro.html">advice</a> about learning
to program in Python remains good, whatever the language. He says learning to program
is like learning a musical instrument - the secret is practice and persistence.
There's also good advice from Yoga and the soft martial arts like Tai Chi;
feel the strain, but don't over-strain. You are not building dumb muscle here.</p>
<p>I'd like to thank the many contributors who caught bad English or bad Rust for me,
and thanks to David Marino for his cool characterization
of Rust as a friendly-but-hardcore no-nonsense knight in shining armour.</p>
<p>Steve Donovan © 2017-2018 MIT license version 0.4.0</p>

                </div></div>||||I||||    * Introduction
    * 1. Basics
    * 2. Structs, Enums and Matching
    * 3. Filesystem and Processes
    * 4. Modules and Cargo
    * 5. Standard Library Containers
    * 6. Error Handling
    * 7. Threads, Networking and Sharing
    * 8. Object-Oriented Programming
    * 9. Parsing with Nom
    * 10. Pain Points

      A Gentle Introduction to Rust

      A Gentle Introduction To Rust

      thanks to David Marino

      Why learn a new Programming Language?

      The aim of this tutorial is to take you to a place where you can read and write enough Rust to fully appreciate the excellent learning resources available online, in particular The Book. It's an opportunity to try before you buy, and get enough feeling for the power of the language to want to go deeper.

      As Einstein might have said, "As gentle as possible, but no gentler.". There is a lot of new stuff to learn here, and it's different enough to require some rearrangement of your mental furniture. By 'gentle' I mean that the features are presented practically with examples; as we encounter difficulties, I hope to show how Rust solves these problems. It is important to understand the problems before the solutions make sense. To put it in flowery language, we are going for a hike in hilly country and I will point out some interesting rock formations on the way, with only a few geology lectures. There will be some uphill but the view will be inspiring; the community is unusually pleasant and happy to help. There is the Rust Users Forum and an active subreddit which is unusually well-moderated. The FAQ is a good resource if you have specific questions.

      First, why learn a new programming language? It is an investment of time and energy and that needs some justification. Even if you do not immediately land a cool job using that language, it stretches the mental muscles and makes you a better programmer. That seems a poor kind of return-on-investment but if you're not learning something genuinely new all the time then you will stagnate and be like the person who has ten years of experience in doing the same thing over and over.

      Where Rust Shines

      Rust is a statically and strongly typed systems programming language. statically means that all types are known at compile-time, strongly means that these types are designed to make it harder to write incorrect programs. A successful compilation means you have a much better guarantee of correctness than with a cowboy language like C. systems means generating the best possible machine code with full control of memory use. So the uses are pretty hardcore: operating systems, device drivers and embedded systems that might not even have an operating system. However, it's actually a very pleasant language to write normal application code in as well.

      The big difference from C and C++ is that Rust is safe by default; all memory accesses are checked. It is not possible to corrupt memory by accident.

      The unifying principles behind Rust are:

        * strictly enforcing safe borrowing of data
        * functions, methods and closures to operate on data
        * tuples, structs and enums to aggregate data
        * pattern matching to select and destructure data
        * traits to define behaviour on data

      There is a fast-growing ecosystem of available libraries through Cargo but here we will concentrate on the core principles of the language by learning to use the standard library. My advice is to write lots of small programs, so learning to use rustc directly is a core skill. When doing the examples in this tutorial I defined a little script called rrun which does a compilation and runs the result:

      rustc $1.rs && ./$1
      

      Setting Up

      This tutorial assumes that you have Rust installed locally. Fortunately this is very straightforward.

      $ curl https://sh.rustup.rs -sSf | sh
      $ rustup component add rust-docs
      

      I would recommend getting the default stable version; it's easy to download unstable versions later and to switch between.

      This gets the compiler, the Cargo package manager, the API documentation, and the Rust Book. The journey of a thousand miles starts with one step, and this first step is painless.

      rustup is the command you use to manage your Rust installation. When a new stable release appears, you just have to say rustup update to upgrade. rustup doc will open the offline documentation in your browser.

      You will probably already have an editor you like, and basic Rust support is good. I'd suggest you start out with basic syntax highlighting at first, and work up as your programs get larger.

      Personally I'm a fan of Geany which is one of the few editors with Rust support out-of-the-box; it's particularly easy on Linux since it's available through the package manager, but it works fine on other platforms.

      The main thing is knowing how to edit, compile and run Rust programs. You learn to program with your fingers; type in the code yourself, and learn to rearrange things efficiently with your editor.

      Zed Shaw's advice about learning to program in Python remains good, whatever the language. He says learning to program is like learning a musical instrument - the secret is practice and persistence. There's also good advice from Yoga and the soft martial arts like Tai Chi; feel the strain, but don't over-strain. You are not building dumb muscle here.

      I'd like to thank the many contributors who caught bad English or bad Rust for me, and thanks to David Marino for his cool characterization of Rust as a friendly-but-hardcore no-nonsense knight in shining armour.

      Steve Donovan © 2017-2018 MIT license version 0.4.0

A Gentle Introduction to Rust
https://stevedonovan.github.io/rust-gentle-intro/
None
None
<div><div>
                                  <hr/>
<h2>What is Rust?</h2>
<p>Rust is one of the most popular programming languages in recent times. Here're some of the features of Rust that make it so popular:</p>

<ul>
	<li><strong>Platform Independent</strong> - You can compile a Rust program on one platform and run it on another platform.</li>
	<li><strong>Performance</strong> - Rust is one of the fastest programming languages. Not only that, but it also requires less memory, which makes it a highly efficient language.</li>
	<li><strong>Safe Concurrency</strong> - Rust doesn't allow programs to modify the same value simultaneously while running the concurrent program.</li>
	<li><strong>Memory Safety</strong> - Rust also provides memory safety to prevent unexpected crashes of its program.</li>
	<li><strong>C++ like Syntax</strong> - Rust is syntactically similar to C++.</li>
</ul>
<hr/>


<p>Here're some of the reasons why you should learn Rust:</p>

<ul>
	<li><strong>Most Loved Programming Language</strong> - According to the report from Stackoverflow, 87% of people love Rust.</li>
	<li><strong>Welcoming Community</strong> - Rust communities are friendly, and you can get all the help from them.</li>
	<li><strong>Fastest-growing programming languages</strong> - It is one of the fastest-growing programming languages designed by keeping today's requirements in mind.</li>
</ul>

<hr/>
<h2>How to learn Rust?</h2>

<ul>
	<li><strong>Rust tutorial from Programiz</strong> - We provide step-by-step tutorials to get you <a href="https://www.programiz.com/rust/getting-started">started with Rust programming</a>. </li>
	<li><strong>Official Rust Documentation</strong> - You can always take references from the <a href="https://doc.rust-lang.org/std/index.html">official Rust documentation</a>.</li>
	<li><strong>Keep Practicing</strong> - The only way you can learn programming is by writing a lot of code.</li>
</ul>                              </div></div>||||I||||      Courses Tutorials Examples

    Try Programiz PRO

          Course Index Explore Programiz
          Python JavaScript SQL HTML R C C++ Java RUST Golang Kotlin Swift C# DSA

            Learn Python practically
            and Get Certified .

            ENROLL

              Popular Tutorials

                    Getting Started With Python
                    Python if Statement
                    while Loop in Python
                    Python Lists
                    Dictionaries in Python
              Start Learning Python

              Popular Examples

                    Add two numbers
                    Check prime number
                    Find the factorial of a number
                    Print the Fibonacci sequence
                    Check leap year
              Explore Python Examples

              Reference Materials

                  Built-in Functions
                  List Methods
                  Dictionary Methods
                  String Methods
                View all
                  Learning Paths
                  Practices

                      Learn Python Interactively

                      Try Programiz PRO

                    Courses

                        Interactive SQL Course
                        Interactive C Course
                        Interactive Java Course
                      View all Courses
                  Python
                  JavaScript
                  SQL
                  HTML
                  R
                  C
                  C++
                  Java
                  More languages

                    Learn Python practically
                    and Get Certified .

                    Try Programiz PRO!

                    Popular Tutorials

                          Getting Started With Python
                          Python if Statement
                          while Loop in Python
                          Python Lists
                          Dictionaries in Python
                    Start Learning Python All Python Tutorials

                    Reference Materials

                        Built-in Functions
                        List Methods
                        Dictionary Methods
                        String Methods
                    View all
                  Python
                  JavaScript
                  R
                  C
                  C++
                  Java
                  Kotlin

                    Learn Python practically
                    and Get Certified .

                    Try Programiz PRO!

                    Popular Examples

                          Add two numbers
                          Check prime number
                          Find the factorial of a number
                          Print the Fibonacci sequence
                          Check leap year
                    All Python Examples

            Learn Rust Programming

              Tutorials Online Compiler
          Tutorials

          Rust is an open-source programming language that is extensively used to build kernels for operating systems, game engines for video games, browser engines for web browsers like Chrome, Firefox, and command-line tools.

          It is one of the fastest programming languages and requires less memory. Our Rust tutorials will guide you to learn Rust programming one step at a time.

              Page Index

                  * Introduction
                  * Control Flow
                  * Data Types
                  * Function
                  * Standard Library Type
                  * Error Handling and Memory
                  * Modules and Packages
                  * Additional Topics
                  * What is Rust?
                  * Why learn Rust?
                  * How to learn Rust?

              Rust Introduction

                    * Getting Started with Rust
                    * Rust Hello World
                    * Rust Comments
                    * Rust Print Output
                    * Rust Variables and Mutability
                    * Rust Data Types
                    * Rust Type Casting
                    * Rust Operators

              Rust Control Flow

                    * Rust if...else
                    * Rust loop
                    * Rust while Loop
                    * Rust for Loop
                    * Rust break and continue

              Rust Data Types

                    * Rust Array
                    * Rust Slice
                    * Rust Tuple
                    * Rust Struct

              Rust Functions

                    * Rust Function
                    * Rust Variable Scope
                    * Rust Closure

              Rust Standard Library Types

                    * Rust Stack and Heap
                    * Rust Vector
                    * Rust String
                    * Rust HashMap
                    * Rust HashSet
                    * Rust Iterator

              Rust Error Handling and Memory

                    * Rust Error Handling
                    * Rust Unwrap and Expect
                    * Rust Ownership
                    * Rust Referenes and Borrowing

              Rust Modules and Packages

                    * Rust Modules
                    * Rust Crate and Package
                    * Rust Cargo Package Manager

              Rust Additional Topics

                    * Rust Pattern Matching
                    * Rust Generics
                    * Rust Traits
                    * Rust File Handling
                    * Rust Macros
                    * Rust Threads

              What is Rust?

              Rust is one of the most popular programming languages in recent times. Here're some of the features of Rust that make it so popular:

                * Platform Independent - You can compile a Rust program on one platform and run it on another platform.
                * Performance - Rust is one of the fastest programming languages. Not only that, but it also requires less memory, which makes it a highly efficient language.
                * Safe Concurrency - Rust doesn't allow programs to modify the same value simultaneously while running the concurrent program.
                * Memory Safety - Rust also provides memory safety to prevent unexpected crashes of its program.
                * C++ like Syntax - Rust is syntactically similar to C++.

              Why Learn Rust?

              Here're some of the reasons why you should learn Rust:

                * Most Loved Programming Language - According to the report from Stackoverflow, 87% of people love Rust.
                * Welcoming Community - Rust communities are friendly, and you can get all the help from them.
                * Fastest-growing programming languages - It is one of the fastest-growing programming languages designed by keeping today's requirements in mind.

              How to learn Rust?

                * Rust tutorial from Programiz - We provide step-by-step tutorials to get you started with Rust programming.
                * Official Rust Documentation - You can always take references from the official Rust documentation.
                * Keep Practicing - The only way you can learn programming is by writing a lot of code.
            Join our newsletter for the latest updates.
              Join
              Join our newsletter for the latest updates.
                Join

        Tutorials

          * Python 3 Tutorial
          * JavaScript Tutorial
          * SQL Tutorial
          * HTML Tutorial
          * R Tutorial
          * C Tutorial
          * C++ Tutorial
          * Java Tutorial
          * Rust Tutorial
          * Go Tutorial
          * Kotlin Tutorial
          * Swift Tutorial
          * C# Tutorial
          * DSA Tutorial

        Examples

          * Python Examples
          * JavaScript Examples
          * C Examples
          * Java Examples
          * Kotlin Examples
          * C++ Examples

        Company

          * 
          * 
          * About
          * Advertising
          * Privacy Policy
          * Terms & Conditions
          * Contact
          * Blog
          * Careers
          * Youtube

        Apps

          * Learn Python
          * Learn C Programming
          * Learn Java

    © Parewa Labs Pvt. Ltd. All rights reserved.

Learn Rust Programming - For Beginners
https://www.programiz.com/rust