Rust Language
This section is designed to provide a quick reference for Rust's language features, syntax, and best practices.
It is not intended to be a beginner's book nor a comprehensive guide, but rather a tool for those who are looking to refresh their knowledge. The Rust book↗ is an excellent resource for complete beginners to get started with. Refer as well to the books chapter for a list of relevant books.
Entry Points
| Define the Entry Point of your Application with the Main Function |
| Define the Entry Point of your Asynchronous Application |
Data Types
| Use Scalar Data Types |
| Declare and Use Compound Data Types: Tuples and Arrays |
| Use the Unit and Never Special Types |
| Declare Strings |
| Declare a Type Alias |
Variables
Constants and Statics
Ownership and Borrowing
Lifetimes
Slices
| Slice Basics |
| Create Slices from Arrays or Vectors |
| String Slices |
| Use a Slice as a Function Argument |
| Common Use Cases |
Control Flow
Execute Code based on a Condition Using if and else |
Create Loops Using loop |
Execute Code Repeatedly While a Condition is True with while |
Iterate Through a Collection with for |
| Exit Early from Blocks |
Pattern Matching
Functions
| Write a Rust Function |
| Write a Generic Function |
| Return a Reference from a Function |
| Work with Diverging Functions |
| Work with Function Pointers |
Closures
| Closure Syntax |
| Force Closure Capture by Value |
| Annotate Closure Types |
| Use Closures as Function Arguments |
Structs
Enumerations
Traits
Impl Trait
Simplify Method Signatures with impl Trait |
Return Opaque Types (esp. Closures and Iterators) with Return-position impl Trait |