Rust Book Club #3: Common Concepts

preview_player
Показать описание
Watch someone stumble through a technical book without the polish you expect. The perfect exercise of schadenfreude and/or masochism.

If you want to learn rust, but don't have friends to talk about it with along the way, hopefully this helps you and you can feel more confident in your learning process.

Rad! 4K and a better camera mount for less shaky footage! This includes a fair bit of efforts on the editing too. As always if you have any comments that can help me improve let me know.

0:00 - Intro
0:30 - The Strength of "Shadow"
3:26 - Constants Vs Immutable Variables
4:50 - Overflowing in Production
5:58 - Unicode as a default
6:44 - Compound crash-course
8:28 - Is Vec a bad default for me?
9:10 - Unexpected Compound Syntax
9:28 - Control Flow & Polymorphism
10:21 - Expressions Vs Statements
12:40 - Implicit and Explicit Returns
13:08 - Control Flow loops are Expressions
13:34 - Changing Iterables during an Iteration
15:42 - Modulos
16:16 - Compiled Language Advantages
17:26 - Truthyness
18:10 - TERMINAL TIME
18:24 - Can we always shadow variables?
19:57 - Can we use polymorphic functions?
20:01 - Purposely Thrashing the Borrow Checker
23:45 - Accept the Borrow Checker warnings
25:15 - Outro

_ Source Material _
The Rust Programming Language by Steve Klabnik and Carol Nichols

______ Links ______
Рекомендации по теме
Комментарии
Автор

Like these videos. Thinking out loud. The borrow checker is your friend.... As you go on, if you go on... That will become clearer.

jonathanmoore
Автор

My understanding of polymorphism is different from the scenario you described. I didn't think it necessarily had to do with function overloading (which rust doesn't support), but instead simply functions which can operate on objects of different types that inherit from the same base or implement the same interface. As somebody else in the comments mentioned, rust's way of accomplishing this is with traits. Great progress, I'm enjoying the videos! Did not know about the 'break <value>;' syntax in a loop before, that's pretty cool

nicholasbicholas
Автор

you'd call non-compiled languages interpreted languages

betsegg
Автор

Rust handles polymorphism via generic types or traits.

cthutu
Автор

The stack layout is very complex and like other system programming languages based on the lifetime and scope of the local variables and parameters. Shadowing is just re-using a variable name, which has it's advantages in Rust. And yes, you can redefine the type. Mutability is required when you change a variable in a sub-scope. For example:

let mut x = 0;
{
// mutate x here
}
// x is still around.

This sub-scope could be in a for loop, closure etc. If you shadowed, then the variable would be lost when you exited the sub-scope.

cthutu
Автор

Vectors grow when they need to, that is length == capacity and you need to add more. I think it doubles the size but I am not sure about that. As for shrinking, there are methods to do that, - it will not do it automatically.

cthutu
Автор

7:50 - tuples are not actually immutable, you can mutate them just fine:
let mut tup = (1, 4.4);
tup.0 = 12;
tup.1 = 1.1;
//etc

9:50 - Rust supports polymorphism via generics and traits (they'll be later in the book). No overloads, though.

wafflelapkin
Автор

Technically, having a semi-colon doesn't mean statement per-say. It is still an expression but an expression of type "( )" - which is the equivalent of the void type in C. You will see that come up in errors.

cthutu