# Rust-Kurs Augsburg 19.2. https://ferrous-systems.github.io/teaching-material/ ## Kursinhalte * Solides Verständnis von Rust-Basics * Arbeiten mit Daten * Mutabilität * Ownership * Borrowing * Rusts Garantien effektiv nutzen * Rusts tooling * Bibliotheksnutzung und Evaluierung * Programmierstrategien * "Refactoring to Speed" * Concurrency * Cross-Kompilierung * unsafe coding * Kryptographie # Swag https://devswag.com/ <Link zum Community-Repos einfügen> # Installation https://www.rust-lang.org/tools/install Rust-Analyzer: https://github.com/rust-analyzer/rust-analyzer ## Aufgaben ### FizzBuzz Aufgabe 1 https://ferrous-systems.github.io/teaching-material/assignments/fizzbuzz.html Solution 0: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=a0ebd75654964e40c67e0e4d3163c406 Solution 1: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=64404e59a9a73193bfedc5333189243a Solution 2: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=c1924fb5f381e32067f33173747ce288 Solution 3: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d3cdd9c0846816eac9e88bdf6bc03e58 Solution 4: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7e1c143a64703bc8e3a2eedc5cce5d76 Solution 5: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=9621d439e53d6b86ae3d038655046a9b Solution 6: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e9a8b41dc694148e83f90502cd2db5d8 ### FizzBuzz Aufgabe 2 Solution 0: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=16317a5752ade622a7898f62fd1232e8 Solution 1: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=81d94661d8ae074e2ad36cb48a4527a9 Solution 2: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ecd301a6a4253993f1e43d888045f2a7 Solution 3: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e7f0f9ebe4eb3817d622e007b3d90269 Solution 4: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=08ae57074430821f820bc9dafb3247e8 ## Aufgabe 3: TCP-Server Solution 0: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2ea03f2cf117ed419550ac7195460e9b Solution 1: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fd7c5f1a3db7d38273f47899a903acca Solution 2: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eebddb465a4ae7b047f0f99e6f3e7597 Sol Echo: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=32975b2b535f9ae91ad398175ad9153d [TCP-Server](/Tglo-XTCTwy4o5vgdTzBBQ) ## Aufgabe 4: Mini-Mailbox Solution 0: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9c6c41d6b24c447f7e18de001c4b729c Solution 1: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a7284bf3111751849a3415325c1b49c7 Solution 2: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=926407c8b74c4eeb8ee86c687a621ca3 Solution 3: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fe614c0d2b5ab9bf3c3e1946509e0291 Solution 4: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=610903dd5e9fd4f6bf91cf562ee33bfb Closures in Rust: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=663143ce681a0f445fe3e862ad357000 RevCounter: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c2cd3754c53781e192b75f6509dd15a3 Functional: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3d461b9d901b357fae433b971b3aa430 [Mini-Mailbox](/A7tWx1ZqRa6lrRHXotQ5gA) ## Aufgabe 5: Parallele Mailbox Solution 0: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f547e2dd019ed7f6a203627f1f8841e7 Solution 1: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4e72e87092ff66933cc0e59d3dab4a7b Solution 2: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fe614c0d2b5ab9bf3c3e1946509e0291 [Parallele Mailbox](/w7F5qdjgREaDkC328G2Ztg) ## Übung Hardware Hardware Plattform: https://www.decawave.com/product/dwm1001-development-board/ [JLink Gdb](https://www.segger.com/products/debug-probes/j-link/tools/j-link-gdb-server/about-j-link-gdb-server/) [Embedded Training repos](https://github.com/ferrous-systems/embedded-trainings) [Cortex M Repos](https://github.com/rust-embedded/cortex-m) [Volatile Register](https://github.com/japaric/volatile-register) ``` JLinkGDBServer -device NRF52832_XXAA -if SWD -speed 4000 ``` ``` sudo apt install gdb-multiarch ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb ``` ```~/embedded-trainings/beginner/utilities/draw-client-tester$ cargo run``` ## Codebeispiele Einfaches Beispiel mit mutable/immutable ownership/borrowing: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ceef99e2efbfa7b7fe71c1f12d3ad24d Vector iter: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c9342784fcc88477ae652eb16b8d425b Parallel-Sum: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=237e82843315942b041e5976618b98e6 Summe mit 2 Threads: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0359d9bdafbfd44e7e1e7fb5396ffddc ## Unsafe Rust The Rustonomicon: https://doc.rust-lang.org/nomicon/index.html ## Crates byteorder: https://docs.rs/byteorder/1.3.4/byteorder/ ## Lesestoff Writing an operating system in Rust: https://os.phil-opp.com/ Rust-Vorlesung: https://www.youtube.com/watch?v=lQ36K1htRDY&list=PL0Ur-09iGhpwMbNiVTBeHmIjs0GuIXhNg ## C-File double.c ``` int double_input(int input) { return input * 2; } ``` ## build.rs ``` extern crate cc; fn main() { cc::Build::new() .file("src/double.c") .compile("libdouble.a"); } ```