25 lines683 B

Lesson 4: Slices

We look at slices the way working developers use it, with examples you can change and run right away.

Full lesson: https://glibcode.net/courses/rust-ownership/lessons/4

Files

  • src/main.rs: string and array slices

Tip: cargo check is much faster than cargo build while you are still fixing errors.

Tip: Read the whole compiler message: the note at the end usually has the fix.

Tip: cargo clippy explains a lot of borrow-checker surprises in plain words.

Run it

cargo run

Exercises

See exercises.md. Ask in the forum once you've tried.