10
0
Fork 0

session 2

This commit is contained in:
Michael Jerger 2025-03-14 16:33:38 +01:00
parent bde7aab26e
commit bc0ec9b3b8
5 changed files with 64 additions and 66 deletions

View file

@ -11,11 +11,17 @@
* 2 Kapitel pro Session
### 14.03.
* Getting Started
* Programming a Guessing Game
* Common Programming Concepts
### 11.04.
### 11.04. 15:00
* Understanding Ownership
* Using Structs to Structure Related Data
* Enums and Pattern Matching
### 09.05.
### 30.05.
### 27.06.

3
important-references.md Normal file
View file

@ -0,0 +1,3 @@
# wichtige Referenzen
1. Std lib: https://doc.rust-lang.org/stable/std/

5
important-tools.md Normal file
View file

@ -0,0 +1,5 @@
# wichtige tools
1. `rustfmt *.rs`: https://rust-lang-de.github.io/rustbook-de/appendix-04-useful-development-tools.html
2. `rustfix `
3. `cargo` : https://doc.rust-lang.org/cargo/

View file

@ -1,65 +0,0 @@
# 2025-03-14
## erste schritte
### installation
1. wie mach ich das in einem container?
2. mein rust-analyzer findet kein projekt?
```bash
rustup component add rustfix
rustup component add clippy
```
### vscodium
1. Multiroot - wie ? Schon war ein Besuch beim betreffenden PR nötig ... ;-()
### cargo
1. oh nein - toml & crates ...
## Guessing Game
1. was ist ein prelude ?
2. was ist ein trait im gegensatz zu einem module?
3. lib reference hat module / description zuklappen / stdin()
4. Fkt mit Nebenwirkungen haben ein `!` ? :-)
5. mut = mutable :-)
1. `&mut guess` vs `&guess` :-)
6. assoziierte Funktion (String::new) == objektorientiert?
7. behandlung v. fehlern wir nicht erzwungen - nur gewarnt ??
8. Uff shadowing? Hoffentlich geht das gut ...
1. zumindest gibt es ein explizites `let`
2. Schatten halten sich an blockgrenzen
3. Typänderungen sind erlaubt ...
## concepts
1. Können in libs Keywords definiert werden?
2. const sind wie java statics geschrieben ...
3. 1_00 == 100
4. `--release` nimmt assertions weg ...
5. Es gibt vector - juhu :-)
6. arrays sind `0` based
7. snake_case_code_convention
8. return ist implizit :-|
9. Fehlerbehandlung ist nett
10. `if number {` tut nicht, juhu :-)
## wichtige tools
1. `rustfmt *.rs`: https://rust-lang-de.github.io/rustbook-de/appendix-04-useful-development-tools.html
2. `rustfix `
3. `cargo` : https://doc.rust-lang.org/cargo/
## wichtige Referenzen
1. Std lib: https://doc.rust-lang.org/stable/std/
## praxisbeispiel: Ein wait for service container
https://varlogdiego.com/kubernetes-wait-until-another-pod-is-ready

49
session-2025-03-14.md Normal file
View file

@ -0,0 +1,49 @@
# 2025-03-14
## first steps
* rustup: Tool für Rust Versionsmanagement
* Compiler 'rustc' erzeugt Binary
* Cargo: Rust Build System und Package Manager
* 'Cargo.toml' ist die Projektkonfig mit Dependencies
* Standard Build ist ein Debug build ('target/debug')
* 'cargo check': Prüfen, ob Code compiliert, ohne zu Bauen.
* 'cargo build --release': Bauen mit Optimierungen aber längerer Compilezeit ('target/release')
## Guessing Game
1. was ist ein prelude ?
2. was ist ein trait im gegensatz zu einem module?
1. trait = interface
3. shadowing
1. zumindest gibt es ein explizites `let`
2. Schatten halten sich an blockgrenzen
4. Deklarative Macros haben ein `!` - Ersatz für Overloading
6. assoziierte Funktion (String::new) == objektorientiert?
* (Mit Typ) Assoziierte Funktion aufrufen mit `::`. Bsp: `let mut s = String::new()`
* wir sind mal gespannt, ob das auch über packagegrenzen hinweg geht
7. behandlung v. integer-overflow fehlern wir nicht erzwungen - nur gewarnt ??
8. Referenz mit `&`. Bsp: `io::stdin().read_line(&mut guess)`
1.. Referenzen sind standardmäßig immutable, daher hier `&mut guess` statt `&guess`
9. Cargo Dependencies folgen semantischer Versionierung:
1.`rand = "0.8.5"` bedeutet `^0.8.5`: mindestens 0.8.5 aber unter 0.9.0
10. If-Expressions direkt für assignments verwenden :)
1.. auch loop
## concepts
1. Können in libs Keywords definiert werden? <--- äääh nein? :P
2. 1_00 == 100
3. snake_case_code_convention
4. Destructuring durch Pattern Matching:
```
let (x, y, z) = tup;
println!("The value of y is: {y}");
```
5. `()`: Tupel ohne Werte. Repräsentiert leeren Wert oder leeren Return Type.
6. arrays sind `0` based
7. `if number {` tut nicht, juhu :-) +1 :)
8. if : Bedingung ohne Klammern
9. Loop Rückgabewerte mit `break`: `break 5;`
10. Tupel ist compound data tuple und kann auch von Funktionen zurück gegeben werden.
11. Typinferenz