This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # code under test, you'll need to know their method name. | |
| # I've made two here to show the tests passing and failing | |
| class Heart | |
| def self.some_recursive_method(num) | |
| if num > 0 | |
| Heart.some_recursive_method(num - 1) | |
| end | |
| end |
-
Slides from my presentation
-
The Rust Programming Language - the official book about all of Rust. This is what I recommend starting with if you want to learn Rust. The chapters most relevant to what I talked about are:
-
The Rustonomicon - an official book all about writing unsafe Rust. Great deep dive of why and how to write good unsafe code.
-
Fearless Concurrency - an official blog post on how safety makes concurrency easier.
-
Memory Leaks are Memory Safe - a blog post written by a core team me
- What is Rust?
- New systems programming language, aiming to replace C & C++
- Fast, safe, and concurrent
- Bad Things the Rust compiler won't let you do
- Only one owner, one mutable borrow, one immutable borrow
- prevents data races
- prevents use after free
- prevents double free
- Uninitialized variables
- Only one owner, one mutable borrow, one immutable borrow
- No nullable pointers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The error is that there's an unused generic G declared... | |
| fn foo<G>() -> String { | |
| String::from("hi") | |
| } | |
| fn main() { | |
| println!("{}", foo()); | |
| // ^ but here is where the error message points to: | |
| // error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Atom { | |
| Number(i32), | |
| } | |
| impl Atom { | |
| fn eval(&self) -> i32 { | |
| match *self { | |
| Atom::Number(n) => n, | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Make these tests pass by filling in conditionals where the blanks currently are! | |
| // Scroll down for hints :) | |
| pub fn fizz_buzz(i: i32) -> String { | |
| __________ { | |
| "FizzBuzz".to_string() | |
| } ___________ { | |
| "Fizz".to_string() | |
| } ___________ { | |
| "Buzz".to_string() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| // I don't want this to have to be mut. | |
| let v = vec![1, 2, 3]; | |
| // Not this either. | |
| let w = vec![3, 4, 5]; | |
| // I want a newly allocated vec that is v + w. | |
| let x = vec_concat(&v, &w); | |
| println!("{:?}", x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---- | |
| // libsass (v3.2.5) | |
| // ---- | |
| div { | |
| margin: 0/0/0/0; | |
| padding: 0 / 0 / 0 / 0; | |
| } |