# Rust Training Course, July 13th - July 28th
This document serves as a living document for everyone to share information, links or note down questions during the Rust course.
Feel free to use the "Questions" section at the bottom of this document liberally to ask questions.
## Topic list
The course will cover the subjects listed in the [core course](https://github.com/ferrous-systems/teaching-material/#core-topics) as well as some subjects decided as a group.
## Dates and Links
All sessions will be held on [google meet].
[google meet]: https://meet.google.com/pqu-fbgu-nhz
## Time
All sessions will be at **8AM Central Time, every Tuesday and Wednesday**
We will go through the detailed schedule and planning during the first day, when we have a chance to collect personal interests.
If someone needs to leave early on a day, please let us know beforehand, this e.g. allows us to reorganize Q&A subjects according to their interests.
## Preparation
### General Topics
Please prepare the following questions:
* What do you want to use Rust for?
* Which are the questions that you've always been interested in?
* If you already worked with Rust: what was the hardest part for you?
* With which of the following (rough) language families do you identify most?
- C/C++
- Objective-C/Swift
- Haskell/ML
- Ruby/Python/Perl/Java
You will need to install Rust through https://rustup.rs/. I can highly recommend doing this on Windows, as installation of the Windows SDK may take some time.
### Specific Installation Notes
> For instructions on Rust installation, these should all be Android developers, which means that they do most of their work on a workstation-class Linux box, using our "gLinux" (yes, Google Linux...) installation setup. The following instructions should work for them, and if they have any questions you can name-drop that I approved it but if they feel uncomfortable, they can "request a gLinux system via go/cloudtop" which makes total sense if you're on the internal network:
>
> Please install Rust on your gLinux system by following the instructions at go/rust#setup
## [Slides](https://ferrous-systems.github.io/teaching-material/)
## Additional Material
* [The Rust Book](https://doc.rust-lang.org/book/)
* [Asynchronous programming with async std](https://book.async.rs/)
- not necessary, but we might cover some subjects)
* [Awesome Rust Streaming](https://github.com/jamesmunns/awesome-rust-streaming)
* [Awesome Rust Mentors](https://github.com/RustBeginners/awesome-rust-mentors)
* [Rust Cheat sheet](https://cheats.rs/)
* [Implementing Vec](https://doc.rust-lang.org/nomicon/vec.html)
* [Embedded Rust WG](https://github.com/rust-embedded/wg)
* [Explaine.rs](https://jrvidal.github.io/explaine.rs/)
* [Oprtator reference](https://doc.rust-lang.org/book/appendix-02-operators.html)
## Playground collection
Playgrounds can be created at [The playground!](https://play.rust-lang.org).
## Exercises
> Shared information around exercises will be placed here.
## Useful tools
[Godbolt compiler explorer](https://rust.godbolt.org/)
[cargo watch](https://crates.io/crates/cargo-watch)
## Code examples
> This is a place to collect interesting code snippets.
## Useful crates
* [log](https://crates.io/crates/log)
* [tracing](https://crates.io/crates/tracing)
* [criterion](https://crates.io/crates/criterion)
* [immutable datatypes](https://crates.io/crates/im)
* [serde](https://crates.io/crates/serde)
## Interesting talks and articles
* [How to build APIs you can't misuse using ownership & borrowing](https://www.youtube.com/watch?v=3Q2hQfYW-XM&index=9&list=PL85XCvVPmGQj9mqbJizw-zi-EhcpS5jTP)
## General notes
> This is a place to collect notes that don't fit anywhere else.
## Topic requests
> This is a place to collect requests on topics to cover during the training
- if possible, touch linked lists and why they are hard in Rust (and in general)
- how can we know if data is stored in stack vs heap in rust?
- NOTE(AJM): Covered
- different flavors of strings in rust
- NOTE(AJM): Covered
- functions that take ownership via
- monomorphized generics
- impl trait
- dyn trait
- NOTE(AJM): Concept of "object safety"
- `any` trait
## Questions
> This is a place to note down questions if you don't want to disturb others.
## Material Covered
### Day 1
- [Overview](https://ferrous-systems.github.io/teaching-material/overview.html#/)
- [The Toolchain](https://ferrous-systems.github.io/teaching-material/installation.html#/)
- [Basic Types](https://ferrous-systems.github.io/teaching-material/basic-types.html#/)
- [Compound Types](https://ferrous-systems.github.io/teaching-material/compound-types.html#/)
- [Control Flow](https://ferrous-systems.github.io/teaching-material/control-flow.html#/)
Detours:
- [Rust Editions](https://doc.rust-lang.org/edition-guide/introduction.html)
- [Learn Rust With Entirely Too Many Linked Lists](https://rust-unofficial.github.io/too-many-lists/)
- niche optimizations and [struct reordering](https://doc.rust-lang.org/nomicon/other-reprs.html)
### Day 2
- [Warmup: `match` and `enum`s](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=66d5bc2c1dd20c2d91553f1e5196deea)
- [Control Flow II](https://ferrous-systems.github.io/teaching-material/control-flow.html#/)
- [Ownership & Borrowing](https://ferrous-systems.github.io/teaching-material/ownership-borrowing-in-brief.html#/)
- the metaphor for owning & borrowing data we use here is a *physical* book!
- [Traits](https://ferrous-systems.github.io/teaching-material/traits.html#/) until slide [14](https://ferrous-systems.github.io/teaching-material/traits.html#/14)
- [Generics](https://ferrous-systems.github.io/teaching-material/generics-basics.html#/)
### Day 3
- [Refresher: Ownership & Borrowing in Rust](https://app.pitch.com/app/player/b55ac23c-1e9b-4a58-b439-0002ae07d8f8/c22d4db1-88b4-4fd7-89f9-6fea1e5f1700/952e7cb8-2974-41e2-9588-867561225f83)
- [Exercise: Files, Option and Result](https://ferrous-systems.github.io/teaching-material/assignments/result-option-assignment.html)
- [sample solution](https://github.com/ferrous-systems/teaching-material/tree/master/assignments/IO-assignment/solution)
- [Drop, Panic, Abort](https://ferrous-systems.github.io/teaching-material/drop-panic-abort.html#/)
- [Exercise: DurableFile](https://ferrous-systems.github.io/teaching-material/assignments/durable-file.html)
### Day 4
- wrap-up durable file exercise
- [Iterators](https://ferrous-systems.github.io/teaching-material/iterators.html#/)
- [Stack and Heap](https://ferrous-systems.github.io/teaching-material/stack-and-heap.html#/)
- [Calc Exercise](https://ferrous-systems.github.io/teaching-material/assignments/calc.html)
- [First mob programming result](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4dfff40109b15569e2ea78faf455e683)
- we recommend you work on this a bit on your own, because we'll be using the calculator for our FFI exercise later. You are absolutely not required, though! We'll provide a sample solution and do a short 10 minte overview starting day 5.
If you have any questions, e-mail us at james.munns@ferrous-systems.com or lotte.steenbrink@ferrous-systems.com.
## Day 5
- [Calc Exercise Solution](https://github.com/ferrous-systems/teaching-material/tree/master/assignments/solutions/calc) demo
- [FFI](https://ferrous-systems.github.io/teaching-material/ffi#/)
- brief diversion: [modules](https://doc.rust-lang.org/rust-by-example/mod.html), imports and visibility
- Exercise: [calc FFI around the world](https://github.com/ferrous-systems/calc-ffi-around-the-world)
- diversion: pointers vs. references in Rust, unsafe (all guarantees still apply in `unsafe` code, but it's up to *you* and not the compiler to enforce them!)
- [`cbindgen](https://github.com/eqrion/cbindgen)
- [`cxx`](https://github.com/dtolnay/cxx)
- [bitvec](https://docs.rs/bitvec/0.22.3/bitvec/index.html)
## Day 6
- wrap-up of "FFI around the world" exercise
- [`bindgen`](https://github.com/rust-lang/rust-bindgen)
- convention: division between `mything-sys` (bindgen-generated) crates and `mything` (wrapper) crates ([brief explanation](https://exercises-2021.ferrous-systems.com/ffi-1-exercise.html#setup))
- [Neon](https://github.com/neon-bindings/neon)
- [Send & Sync](https://ferrous-systems.github.io/teaching-material/send-and-sync.html#/_relationships)
- quick detour: [lifetimes](https://ferrous-systems.github.io/teaching-material/lifetimes.html#/)
- Mutexes and concurrent access
- [Mutex](https://doc.rust-lang.org/book/ch16-03-shared-state.html)
- [Arc](https://doc.rust-lang.org/std/sync/struct.Arc.html) (Send&Sync) / [Rc](https://doc.rust-lang.org/book/ch15-04-rc.html) (may be faster)
- [RwLock](https://doc.rust-lang.org/std/sync/struct.RwLock.html) for single-writer, multiple-reader situations
- [Threading](https://doc.rust-lang.org/book/ch16-01-threads.html)
- [Closures](https://ferrous-systems.github.io/teaching-material/closures.html#/)
- [take-home "fill in the blanks" exercise](https://ferrous-systems.github.io/teaching-material/fill_in_the_blanks/closures.html)
- Concurrency and parallelism
- executors: (see also: [tokio](https://tokio.rs), [smol](https://docs.rs/smol/1.2.5/smol/), [async-std](
https://docs.rs/async-std/1.9.0/async_std/))
- check out the exercises at the bottom of our [Teaching Material](https://ferrous-systems.github.io/teaching-material/index.html), but note that they build on non-async exercises so you may have to backtrack a little