Rust is a big language. It is obviously very carefully designed, and with features for serious software development. Giving an intro in a few weeks has been a challenge.
There are a lot of things I wish I could have talked about…
Language features:
match
blocks, if let
, while let
.dbg!
: like println!
but programmer-specific.Data structures:
So much cool stuff in the standard library:
std::collections
: more standard library collections.std::simd
: (still-experimental) SIMD operations.Wrapping
and Saturating
numeric containers that ask for slightly different arithmetic behaviour.We have been writing Rust and compiling to machine code, as one usually does. But there are some other contexts where Rust is written/executed that are worth mentioning.
Rust has done a lot to keep us safe
. Sometimes, those restrictions prevent specific memory manipulations that are necessary.
Rust can contain unsafe blocks and functions which remove a few of the language restrictions. In particular, you can follow a raw pointer in unsafe Rust.
Rust can be compiled to WebAssembly (wasm), so it can run in a web browser.
The Rust compiler can actually interpret a big subset of Rust. This allows many calculations to be evaluated at compile time.
This includes function calls, if
, loops. Example: a const
built from a loop. (Succeeds only in rustc ≥1.46.)
Rust has obviously borrowed a lot from Haskell and has many functional features (but there's no question it's imperative):
Maybe
≈Option
, etc;It also has similarities to C++:
I also feel many stylistic similarities to Python.
for
loop is a for each;
But Rust also has a lot that isn't in any other (commonly-used) language: enforced ownerhsip and memory safety.
So, I don't know what Rust is. It's either the future, or it's from the future.