Add lesson 1: Hello, Cargo

Mira Kovac 10 months ago
parent 5031a8011e commit f024b7f22fa7648022e22c552dc532bc93073648
4 changed files with 36 additions and 0 deletions
+6-0lessons/01-hello-cargo/Cargo.toml ADDED
@@ -0,0 +1,6 @@
1+[package]
2+name = "hello_cargo"
3+version = "0.1.0"
4+edition = "2021"
5+
6+[dependencies]
+19-0lessons/01-hello-cargo/README.md ADDED
@@ -0,0 +1,19 @@
1+# Lesson 1: Hello, Cargo
2+
3+This lesson covers hello, Cargo. You'll read a short explanation, try three small exercises and finish with a quiz.
4+
5+Full lesson: [https://glibcode.net/courses/rust-ownership/lessons/1](https://glibcode.net/courses/rust-ownership/lessons/1)
6+
7+## Files
8+
9+- `src/main.rs`: a first Cargo project
10+
11+## Run it
12+
13+```sh
14+cargo run
15+```
16+
17+## Exercises
18+
19+See [exercises.md](exercises.md). Ask in the forum once you've tried.
+5-0lessons/01-hello-cargo/exercises.md ADDED
@@ -0,0 +1,5 @@
1+# Exercises: lesson 1
2+
3+1. Explain the example to someone who hasn't taken the course. Which part was hardest to explain?
4+2. Time yourself: rewrite the example from memory in 10 minutes, then diff it against the original.
5+3. Make the example ask for its input instead of using a fixed value.
+6-0lessons/01-hello-cargo/src/main.rs ADDED
@@ -0,0 +1,6 @@
1+fn main() {
2+ let name = "Rustacean";
3+ println!("Hello, {name}!");
4+ let squares: Vec<u32> = (1..=5).map(|n| n * n).collect();
5+ println!("{squares:?}");
6+}