---
marp: true
theme: default
style: @import url('https://unpkg.com/tailwindcss@^2/dist/utilities.min.css');
---
Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.
Rust’s rich type system and ownership model guarantee memory-safety and thread-safety — enabling you to eliminate many classes of bugs at compile-time.
Rust foundation platinum members:
Rust foundation silver members:
- Compiled code about same performance as C / C++, and excellent memory and energy efficiency.
- Can avoid 70% of all safety issues present in C / C++, and most memory issues.
- Strong type system prevents data races, brings 'fearless concurrency' (amongst others).
- Seamless C interop, and dozens of supported platforms (based on LLVM).
- "Most loved language" for
4567 years in a row. 🤷♀️ - Modern tooling:
cargo
(builds just work),clippy
(550+ code quality lints),rustup
(easy toolchain mgmt).
- Steep learning curve; compiler enforcing (esp. memory) rules that would be "best practices" elsewhere.
- Missing Rust-native libs in some domains, target platforms (esp. embedded), IDE features.
- Longer compile times than "similar" code in other languages.
- No formal language specification, can prevent legal use in some domains (aviation, medical, …).
- Careless (use of
unsafe
in) libraries can secretly break safety guarantees.
[eXclusive OR] also known as exclusive disjunction is a logical operation that is true
if and only if its arguments differ (one is true, the other is false).
Rust’s type system enforces the discipline of aliasing XOR mutability
- (AXM, for short): a value of type
T
may either have multiple aliases (called shared references), of type&T
, or it may be mutated via a unique, mutable reference, of type&mut T
- BUT it may not be both aliased and mutable at the same time
In computing, a null pointer or null reference is a value saved for indicating that the pointer or reference does not refer to a valid object. Programs routinely use null pointers to represent conditions such as the end of a list of unknown length or the failure to perform some action; this use of null pointers can be compared to nullable types and to the Nothing value in an option type.
Option
type
represents an optional value: every Option
is either Option::Some
(contains a value,
or Option::None
(essentially null
). Option
s are used
frequently in Rust with a number of uses:
- Initial values
- Return values for functions that are not defined over their entire input range (partial functions)
- Return value for otherwise reporting simple errors, where None is returned on error
- Optional struct fields
- Struct fields that can be loaned or “taken”
- Optional function arguments
- Nullable pointers
- Swapping things out of difficult situations
// keyword
// | Type of returned value that will be
// | | held by `Some(T)`
// v v
pub enum Option<T> { // < Body of enum option,
None, // | When Option is unwrapped:
Some(T), // | it will be either `None`
} // < or `Some(T)`
- what is interesting about Rust?
- why do you like Rust?
- what does the borrow checker do in Rust?
- what is the best way to handle nullable types in Rust (hint: talk about the
Option
type)
- Compiled (Rust) vs. Interpreted languages (Python)
- Strong Typing (Rust) vs. Weak Typing (Python)
- The borrow checker (how does Rust enforce AXM)
null
: The Billion Dollar Mistake- Object inheritance (Python) vs. Compositional inheritance (Rust)