Advent of Code 2021 ! I’m trying Rust this year, let’s see how it goes :)
For reference, I only know Python and I have absolutely no experience with typed languages nor with compiled languages.
- Day 1: Use of
cargo, a rust project’s structure, thecargo.tomlfile and the[[bin]]keyword. - Day 2: The difference between a
Stringand astr, theoptiontype and theunwrap()method, a first try at simple pattern matching and string splitting withlines()andsplit_whitespace()methods. - Day 3: First brush with the borrow checker and lifetimes, the definition of function with the
fnkeyword, use ofVec<&str>. - Day 4: Using
HashMaps, the creation of customstructs,constandenums, using theimplandpubkeywords,#[derive(PartialEq)],breakandcontinuestatements can be scoped to target outer loops, separating code in different files and usingcrate::andmod, using a constructor to initiate members of our structs, theretainmethod for vectors, dereferencing a value with*. - Day 5: Deriving more stuff like
Hash, how to write and run tests, writing a function returningResults(and the difference between returning a result and panicking).