Log In
Join
for free
Log In
Join
for free
Back To Module Home
The Ultimate Guide to Rust Programming
0% completed
Hello World and variables
Hello World
What Does That Mean?
Interpolation
Variables
More Math!
Multiple Variables and Shadowing
Types
Summary
Exercises
Anatomy of Rust
Introduction
Pairing and Nesting
Layout
Comments
Expressions, Values, and Types
Variables, Again
Effects Versus Results
Blocks and Statements
Summary
Exercises
Functions
Hello World, Again
Function Parameters
Function Results
Multiple Parameters
Variable and Parameter Scope
Anatomy of a Function
Calling Functions
Is main Special?
Summary
Exercises
Boolean
Equality
Assertions
Comparison Operators
Functions Returning Booleans
The Not Operator
Not-ing Other Comparison Operators
And/Or
Summary
Exercises
Conditionals
Hello If
A Note on Semicolons
Else
Else If
Evaluating to Values
Factorial and Recursion
Summary
Exercises
Mutable variables and while loops
While Expressions/Loops
Failed Attempt: Shadowing
Almost Correct: Assignment
More Than Once!
Counting
Sum
Nested Loops
Mutation and Shadowing
Let Without Assignment
Summary
Exercises
Structs and ownership
All This Fruit!
Struct
Call Another Function
Ownership and Moving
Copy Values
Make a Copy
Move Out!
Increasing Fruit
Upper and Lower Case
Summary
Exercises
References
Borrow
Mutable References
What's In a Reference?
Deref
Lifetimes of References
Mutating and Borrowing
Multiple References
Single Mutable Reference
Mutable to Immutable
Summary
Exercises
Methods
Hello Method Calls!
Type Inference
Side Note: Underscores in Numbers
Negative Numbers are Annoying
Hello Method Implementations!
Methods by Reference
Static Methods
The Self Type
Method Call Chaining
Summary
Exercises
Strings
Bits, Bytes, and Memory
Dynamically Sized Types
Program Memory
Lifetimes of String Literals
Owned Strings
The Type of Owned Strings
Moving Strings
Borrowing a String
A Better Person
The format! Macro
Freeing
Summary
Exercises
Arrays, Vecs, and slices
Arrays
Indexing
Slices
The Relation to String Slices
Vec
Slicing a Slice
Summary
Exercises
Traits
Double Double
Trait Bounds
Parameterized Fruit
Display
Clone and Derive
Copy and Marker Traits
Debug
Partial Equal, Partial Order
Using Traits From std
Multiple Bounds
Associated Types
Summary
Exercises
Enums
Get Me a Job
Using Variants
Pattern Matching
Commas and Braces
More Teachers
Methods for Enums
Optional Results
Capturing with Match
Summary
Exercises
Iterators and for loops
Count to 10
Iterators
Inclusive Range Expressions
Iterating Over a Vec
IntoIterator
The Rule of 3
Arrays and Slices
Iterating on Strings
Generic Iterator Functions
Summary
Exercises
Early exit
Time for a Break
Go On...
Replacing For With While
Returning The Favor
Salaries
Let Me Ask You a Question
Failing With Style
Errors in main
Summary
Exercises
Appendix
Install Rust on Your Local Machine
Conclusion
Final Remarks
Slices
Let’s add another number to our array. Can you find the bug?