Rust 101 Course Notes
How to Use This
As you go through the course:
-
Capture what clicks - when something makes sense, write it in YOUR words
-
Capture what confuses - come back to it, ask me
-
Code snippets - copy patterns you’ll reuse
Section 2: Variables & Data Types
2.a: Data Types
Rust provides basic types that are universally useful:
| Type | Description | Examples |
|---|---|---|
Boolean |
Logical true/false |
|
Integer |
Whole numbers (positive and negative) |
|
Float |
Decimal numbers (double precision) |
|
Character |
Single character (in single quotes) |
|
String |
Text (in double quotes) |
|
2.b: Variables
- Variable
-
Assigns data to a temporary memory location. Can be set to any value and type.
|
Immutability by Default
Rust variables are immutable by default. This is intentional:
Use |
- Immutable
-
Cannot be changed after assignment
- Mutable
-
Can be changed (requires
mutkeyword)
Variable Examples
// Immutable variables (default)
let two = 2;
let hello = "hello";
let j = 'j';
let my_half = 0.5;
let quit_program = false;
// Mutable variable (can be changed)
let mut my_name = "Bill";
my_name = "Bob"; // OK - it's mutable
// Using a previously defined variable
let your_half = my_half;