Edit the Rust example below and click Run to preview expected output notes.
Rust Tutorial
Learn Rust Tutorial with a small example you can edit and run.
cargo new my-app
cargo run
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
println!("Welcome to Rust"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust TutorialRust HOME
Learn Rust HOME with a small example you can edit and run.
cargo new my-app
cargo run
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
println!("Welcome to Rust"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust HOMERust Intro
Learn Rust Intro with a small example you can edit and run.
cargo new my-app
cargo run
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
println!("Welcome to Rust"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust IntroRust Get Started
Learn Rust Get Started with a small example you can edit and run.
cargo new my-app
cargo run
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
println!("Welcome to Rust"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust Get StartedRust Syntax
Learn Rust Syntax with a small example you can edit and run.
fn main() {
println!("Hello");
}
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let score = 82; | Declares a variable (mutable with let mut). |
let result = if score >= 75 { "Pass" } else { "Fail" }; | Declares a variable (mutable with let mut). |
println!("{}", result); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust SyntaxRust Output
Learn Rust Output with a small example you can edit and run.
println!("Hello");
print!("No newline");
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
print!("Hi"); | Print macro outputs text. |
print!(" "); | Print macro outputs text. |
println!("Rust"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust OutputRust Comments
Learn Rust Comments with a small example you can edit and run.
// line comment
/* block comment */
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
/* multi-line comment */ | Rust line. |
println!("Comments don't change output"); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust CommentsRust Variables
Learn Rust Variables with a small example you can edit and run.
let x = 7;
let mut y = 0;
y += 1;
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let name = "Mana"; | Declares a variable (mutable with let mut). |
let mut level = 1; | Declares a variable (mutable with let mut). |
level += 1; | Rust line. |
println!("{} level {}", name, level); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust VariablesRust Data Types
Learn Rust Data Types with a small example you can edit and run.
let a: i32 = 7;
let b: f64 = 3.14;
let ok: bool = true;
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let a: i32 = 10; | Declares a variable (mutable with let mut). |
let b: f64 = 3.5; | Declares a variable (mutable with let mut). |
let ok: bool = true; | Declares a variable (mutable with let mut). |
let c: char = 'A'; | Declares a variable (mutable with let mut). |
println!("{} {} {} {}", a, b, ok, c); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust Data TypesRust Constants
Learn Rust Constants with a small example you can edit and run.
const MAX: i32 = 100;
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
const MAX: i32 = 100; | Declares a constant. |
fn main() { | Program entry point. |
println!("{}", MAX); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust ConstantsRust Operators
Learn Rust Operators with a small example you can edit and run.
let sum = a + b;
let gt = a > b;
let and = ok && other;
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let a = 7; | Declares a variable (mutable with let mut). |
let b = 3; | Declares a variable (mutable with let mut). |
println!("{}", a + b); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust OperatorsRust Booleans
Learn Rust Booleans with a small example you can edit and run.
let ok = (a >= 10) && (b < 5);
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let a = 10; | Declares a variable (mutable with let mut). |
let b = 2; | Declares a variable (mutable with let mut). |
let ok = (a >= 10) && (b < 5); | Declares a variable (mutable with let mut). |
println!("{}", ok); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust BooleansRust Strings
Learn Rust Strings with a small example you can edit and run.
let s = String::from("hi");
let t = &s;
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let mut s = String::from("Mana"); | Declares a variable (mutable with let mut). |
s.push_str(" Coding"); | Rust line. |
println!("{}", s); | Print macro outputs text. |
} | Rust line. |
- 1Ownership rules help prevent use-after-free and data races at compile time.
- 1Cloning too much to “make errors go away”.
- 1Borrow when you can, clone when you must.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust StringsRust If..Else
Learn Rust If..Else with a small example you can edit and run.
let label = if score >= 75 { "Pass" } else { "Fail" };
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let score = 75; | Declares a variable (mutable with let mut). |
if score >= 90 { println!("A"); } | Print macro outputs text. |
else if score >= 75 { println!("B"); } | Print macro outputs text. |
else { println!("C"); } | Print macro outputs text. |
} | Rust line. |
- 1Control flow powers validation, parsers, and state machines.
- 1Ignoring the wildcard arm in match or missing edge cases.
- 1Use match for exhaustive handling and test boundaries.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust If..ElseRust Match
Learn Rust Match with a small example you can edit and run.
match x {
0 => "zero",
_ => "other",
}
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let day = 3; | Declares a variable (mutable with let mut). |
let name = match day { | Declares a variable (mutable with let mut). |
1 => "Mon", | Rust line. |
2 => "Tue", | Rust line. |
3 => "Wed", | Rust line. |
_ => "Other", | Rust line. |
}; | Rust line. |
println!("{}", name); | Print macro outputs text. |
} | Rust line. |
- 1Control flow powers validation, parsers, and state machines.
- 1Ignoring the wildcard arm in match or missing edge cases.
- 1Use match for exhaustive handling and test boundaries.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust MatchRust Loops
Learn Rust Loops with a small example you can edit and run.
loop { break; }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let mut i = 0; | Declares a variable (mutable with let mut). |
loop { | Infinite loop (use break to exit). |
i += 1; | Rust line. |
if i == 3 { break; } | Conditional branch. |
} | Rust line. |
println!("{}", i); | Print macro outputs text. |
} | Rust line. |
- 1Control flow powers validation, parsers, and state machines.
- 1Ignoring the wildcard arm in match or missing edge cases.
- 1Use match for exhaustive handling and test boundaries.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust LoopsRust While Loops
Learn Rust While Loops with a small example you can edit and run.
while i < 5 { i += 1; }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let mut n = 1; | Declares a variable (mutable with let mut). |
let mut sum = 0; | Declares a variable (mutable with let mut). |
while n <= 5 { | Loop while condition is true. |
sum += n; | Rust line. |
n += 1; | Rust line. |
} | Rust line. |
println!("{}", sum); | Print macro outputs text. |
} | Rust line. |
- 1Control flow powers validation, parsers, and state machines.
- 1Ignoring the wildcard arm in match or missing edge cases.
- 1Use match for exhaustive handling and test boundaries.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust While LoopsRust For Loops
Learn Rust For Loops with a small example you can edit and run.
for i in 1..=3 { println!("{}", i); }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
for i in 1..=3 { | Loop over an iterator/range. |
print!("i={} ", i); | Print macro outputs text. |
} | Rust line. |
} | Rust line. |
- 1Control flow powers validation, parsers, and state machines.
- 1Ignoring the wildcard arm in match or missing edge cases.
- 1Use match for exhaustive handling and test boundaries.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust For LoopsRust Functions
Learn Rust Functions with a small example you can edit and run.
fn add(a: i32, b: i32) -> i32 { a + b }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn add(a: i32, b: i32) -> i32 { a + b } | Declares a function. |
fn main() { | Program entry point. |
println!("{}", add(4, 6)); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust FunctionsRust Scope
Learn Rust Scope with a small example you can edit and run.
{ let x = 1; }
// x not available here
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let x = 1; | Declares a variable (mutable with let mut). |
{ | Rust line. |
let x = 2; | Declares a variable (mutable with let mut). |
println!("{}", x); | Print macro outputs text. |
} | Rust line. |
println!("{}", x); | Print macro outputs text. |
} | Rust line. |
- 1Rust is used for performance-critical and reliability-focused software.
- 1Fighting the borrow checker instead of learning ownership rules.
- 1Model ownership clearly and keep functions small.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust ScopeRust Ownership
Learn Rust Ownership with a small example you can edit and run.
let s = String::from("hi");
// s moved
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let s1 = String::from("hello"); | Declares a variable (mutable with let mut). |
let s2 = s1; | Declares a variable (mutable with let mut). |
println!("{}", s2); | Print macro outputs text. |
} | Rust line. |
- 1Ownership rules help prevent use-after-free and data races at compile time.
- 1Cloning too much to “make errors go away”.
- 1Borrow when you can, clone when you must.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust OwnershipRust Borrowing
Learn Rust Borrowing with a small example you can edit and run.
fn len(s: &String) -> usize { s.len() }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn len(s: &String) -> usize { s.len() } | Declares a function. |
fn main() { | Program entry point. |
let s = String::from("Mana"); | Declares a variable (mutable with let mut). |
println!("{}", len(&s)); | Print macro outputs text. |
println!("{}", s); | Print macro outputs text. |
} | Rust line. |
- 1Ownership rules help prevent use-after-free and data races at compile time.
- 1Cloning too much to “make errors go away”.
- 1Borrow when you can, clone when you must.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust BorrowingRust Data Structures
Learn Rust Data Structures with a small example you can edit and run.
Arrays, Vec<T>, tuples, HashMap<K,V>, structs, enums
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
println!("Arrays, Vec, tuples, HashMap, structs, enums"); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust Data StructuresRust Arrays
Learn Rust Arrays with a small example you can edit and run.
let a = [1, 2, 3];
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let nums = [1, 2, 3, 4]; | Declares a variable (mutable with let mut). |
let mut sum = 0; | Declares a variable (mutable with let mut). |
for x in nums { sum += x; } | Loop over an iterator/range. |
println!("{}", sum); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust ArraysRust Vectors
Learn Rust Vectors with a small example you can edit and run.
let v = vec![1, 2, 3];
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let mut v = vec![1, 2, 3]; | Declares a variable (mutable with let mut). |
v.push(4); | Rust line. |
let sum: i32 = v.iter().sum(); | Declares a variable (mutable with let mut). |
println!("{}", sum); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust VectorsRust Tuples
Learn Rust Tuples with a small example you can edit and run.
let t = (1, "a");
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
fn main() { | Program entry point. |
let t = (7, "hi"); | Declares a variable (mutable with let mut). |
println!("{} {}", t.0, t.1); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust TuplesRust HashMap
Learn Rust HashMap with a small example you can edit and run.
use std::collections::HashMap;
let mut m = HashMap::new();
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
use std::collections::HashMap; | Rust line. |
fn main() { | Program entry point. |
let mut m = HashMap::new(); | Declares a variable (mutable with let mut). |
m.insert("SQL", 2); | Rust line. |
println!("{}", m["SQL"]); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust HashMapRust Structs
Learn Rust Structs with a small example you can edit and run.
struct User { name: String }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
struct User { name: String } | Rust line. |
fn main() { | Program entry point. |
let u = User { name: String::from("Mana") }; | Declares a variable (mutable with let mut). |
println!("{}", u.name); | Print macro outputs text. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust StructsRust Enums
Learn Rust Enums with a small example you can edit and run.
enum Status { Active, Inactive }
Edit the Rust code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
enum Status { Active, Inactive } | Rust line. |
fn main() { | Program entry point. |
let s = Status::Active; | Declares a variable (mutable with let mut). |
match s { | Pattern matching with match. |
Status::Active => println!("Active"), | Print macro outputs text. |
Status::Inactive => println!("Inactive"), | Print macro outputs text. |
} | Rust line. |
} | Rust line. |
- 1Data structures model your domain and impact performance and readability.
- 1Picking the wrong collection type for the job.
- 1Start simple (Vec/struct), then optimize with profiling.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Rust Systems Rust Enums