-
**
Basic programming: loops, conditions, variables, and tests. -
**
Splitting strings, 2D arrays, parsing integers from strings, arithmetic. -
**
Hashmaps (comparable objects), sets, refactoring -
**
Embarrassingly parallelizable problems, refactoring, use of existing libraries -
**
Strings, unit testing, regular expressions -
**
Mutable state, object-oriented programming, procedural programming, polymorphism, abstraction -
**
Parsing, dynamic programming,$O(2^n)$ -
**
String encoding, look-ahead parsers (peeking)
- I really liked
go run
and how Go made it so easy to build an executable from a.go
file, but I never got comfortable withgo install
andgo get
from Github.rustc
can compile a Rust source file directly, which is fine. - A cool strength Rust has over Go is that a package may contain
multiple binary crates
in the
src\bin
directory. This is the structure I'm using for Advent of Code. - Calls to
dbg!
andassert!
transfer ownership of the arguments. This means you need to pass references (&
) instead of values. - Tests in Rust are excellent! Use
cargo test
for all your testing needs. See day 4. - I would be interested to go back to day 4 to do this in parallel. This would have been easy in Go.
- Looks like the compiler will (at least, by default) completely ignore errors (including syntax errors) in your tests.
- Like Go, you can declare a variable in
if let
. For example:if let Error(e) = f(x) { g(e); }
. - You can also
while let
, which avoids an implicit move of the iterator inside afor
loop (see day 8). - Lifetime annotations might be necessary when mutating hash maps in a function.
- The
memoize
library was not as effortless as@cache
in Python. - Rayon, on the other hand, is amazing! You should be able to replace
iter
withpar_iter
for easy parallelization.
Enter the command rustup doc
to access the Rust Programming Language ("the book"), Rustonomicon, examples, API documentation, and a lot more.
Examples:
rustup doc std::collections
rustup doc for