📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
@ChumX1003 жыл бұрын
Chapter 15 was the first hard "wall" I faced learning Rust. Glad to have these videos to go over and digest the content a bit better.
@Nounearthlyglow2 жыл бұрын
I'm right there with ya' Duke.
@voluptua Жыл бұрын
I feel the same @ChumX100
@Gigachad-mc5qz9 күн бұрын
For me it was pngme book
@linjianru2 жыл бұрын
Difficult concepts become easy because of you! Thank you!
@barisballi70 Жыл бұрын
Wow, I was wondering why we can pass &String typed values to the functions that expect &str types, this dereferencing chain explains a lot. I know that, go also uses a similar approach when it comes to dereferencing, but go compiler is a thousand times worse when making suggestions.
@yapayzeka2 жыл бұрын
this is the hardest episode so far.
@karlheinzneugebauer2 жыл бұрын
Holy moly! I write in C++, PL/SQL, Bash, JS, and sometimes PHP every day and I think Rust is really hard. But thankfully we got a wonderful compiler and a teacher like you.
@mihaigalos2792 жыл бұрын
Bogdan, I suggest using "fn new(..) -> Self" default constructor signatures - notice the capital S. This reduces typing, ensures you don't need to propagate generic types into the output and finally, ensures you automatically propagate changes to generics into the return type (should they change).
@0scarcalderon2 жыл бұрын
Thank you for this detailed explanation! As English is not my native language, the word of deref or dereference doesn't make too much sense to me. It sounds for me like the reference is being removed, but it is actually about not performing operations against the reference, but "fetching" the actual value being referenced to perform operations against it right?
@Tony_Goat2 жыл бұрын
Yes, that's the best way to think about it. It makes more sense to use it as a verb in this context rather than a noun. To reference something means to mention it in shorthand. For example, if one piece of writing references another, they simply use the title of the mentioned work rather than including the entire work. To dereference something is to undo a reference, or rather find and turn that mention of the writing back into the full original work, so you're no longer mentioning it by title. Similarly in programming, a reference is a way to mention data in shorthand (using its memory address in the background as the title), and to dereference is to turn that mention (the address) back into the data.
@idiot7leon2 жыл бұрын
Thanks! Very helpful!
@bryson26622 жыл бұрын
This is blowing my mind.
@domtorque3 жыл бұрын
Now I get it!!!! Thank you so much!
@lee452833 жыл бұрын
Thanks Bogdan, another great video!
@centaurii443 жыл бұрын
You seriously need to be a CS professor. When I was reading the book I could not wrap my head around Deref but after watching this video everything made sense.
@jonathanmoore56193 жыл бұрын
Again, nice work. Thank you.
@hafizjoundysyafie81843 жыл бұрын
very good explanation, thank you
@hussainaqeel73713 жыл бұрын
Good stuff! Thanks!
@jeffg46862 жыл бұрын
I was thinking about this a minute. The deref method of Deref deferences the smart pointer to yield a reference, so it seems to do a double deref in a way as I see it if dereffing the smart pointer yields the same as the integer "value" itself. fn deref(&self) -> &Self::Target; // see, the reference is returned, not the value So compiler must be doing some kind of double duty here, apply another deference on the reference returned from deref to get actual underlying value. idk, something they don't explain well at this point. Cause if deref returns a reference, how could it equal "5" literal integer value?
@abhishek.rathore2 жыл бұрын
Yes. When he said *y is same as *(y.deref()) this double derefencing thing is implied. y.deref() gives us a reference to the underlying data which can be considered wrongly named as it is not dereferencing but is returning a reference. But since Rust automatically converts *y into this latter form, it actually is derefencing by getting data from the reference returned by the deref function. So by the name it is double derefencing but in actuality it is being dereferenced only once and that is after calling the deref function.
@jeffg46862 жыл бұрын
@@abhishek.rathore - thanks, good explanation
@1234fewgfwe6 ай бұрын
THE RUST GANG!!!
@caseyyeow16493 жыл бұрын
when will the video for asynchronous programming in Rust be ready?
@DipsAndPushups Жыл бұрын
If you put an instance of a struct that doesn't implement deref trait into a box then you would not be able to dereference the box right? If I write let a = Box::from(MyStruct::new()); I will not be able to write *a unless MyStruct implements the deref trait, correct?
@bjugdbjk2 жыл бұрын
How reference (&) type is calling defef method in mybox @ 8:06, normally deref gets called by *, am I correct, am I missing anything
@FaranAiki2 жыл бұрын
I do not quite understand what you meant. Which `mybox` variable?
@islamibrahim81212 жыл бұрын
Hi, please do a series on async rust.
@samaygandhi71822 жыл бұрын
Awesome video !!
@denizsincar293 ай бұрын
Does dereferencing a reference return the original type? Than how borrowing rules apply? let a = String::new(); let b = &a; let c=*b; // c is a? Than what happens if i dereference a referenced parameter inside a function? Does it still work with the reference?
@guozw4980 Жыл бұрын
👍
@abhinavchavali14433 жыл бұрын
Any way you can post twice a week instead of once?
@ИнякинАлександр3 жыл бұрын
Where my Rust Cheatsheet?
@letsgetrusty3 жыл бұрын
Coming soon! Still working on it.
@hermannpaschulke15833 жыл бұрын
Also, you can simply do the dot operator "." on types that implement Deref. Like so : x.foo(). In C and C++ you need to use the arrow -> instead.
@minhnguyen-q1z7w9 ай бұрын
this is soo hard lmao
@TejasPatil0Ай бұрын
this is a beutiful language
@benjaminhon86 Жыл бұрын
Wish they just made C with borrow checker. Instead of all these magic
@MrGreen-kq4ds3 жыл бұрын
"automagical" coercion
@dagher.a2473 жыл бұрын
First...
@rishabhagrawalzra Жыл бұрын
if assert_eq!(5, y) doesn't work then why println!("{y}") works?
@GolangDojo3 жыл бұрын
📝 Get notified when the Rust Cheatsheet comes out ;) letsgetrusty.com/