Тёмный

You MUST KNOW These Traits in Rust 

Oliver Jumpertz
Подписаться 1,1 тыс.
Просмотров 10 тыс.
50% 1

Although Rust's standard library is pretty small compared to other languages, it comes with most of the batteries included. It even standardizes conversions with a few important traits that any Rust developer should know about.
So, what better to do than to take a look at these traits, learn about them, and get you ready to master conversions in Rust?!
----------
🕖 Timestamps:
00:00 Intro
00:46 From and Into
06:35 TryFrom and TryInto
11:25 AsRef
16:38 AsMut
18:03 Outro
----------
❓ Who the hell am I?
Hey, if we haven't met yet, I'm Oliver, and I'm a software engineer. I started programming over two decades ago as a hobby. Nowadays, I design and build huge distributed systems in the video on demand space.
----------
📺 What else to watch?
What about this one? ⬇️
How to create your OWN Link Shortener in Rust - • How to create your OWN...
----------
🙌🏻 You can find me here:
My blog: oliverl.ink/blog
My Twitter: / oliverjumpertz

Наука

Опубликовано:

 

24 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 74   
@Hellbending
@Hellbending 2 месяца назад
Thank GOD someone that ACTUALLY explains how these things work is making videos on it - you’re a blessing man Ty Ty ❤❤❤❤
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! Stay ready for the next one. We're going to explore a lot more in-depth things about Rust. 😁🙌🏻
@xenofly94
@xenofly94 2 месяца назад
Actually sad that this isn't a series already. You've explained those traits perfectly and it would be awesome to have similar videos for other common std lib traits
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! Well…I might have gotten a few more content ideas now. 💛 Already working on the next video BUT I will definitely take a look at the std lib and see what else is worth being explained and explored a little more. ☺️
@Avogadro37540
@Avogadro37540 2 месяца назад
17:03 Perfect! Should be my new wallpaper moving forward ^^
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Haha, I can send you the png if you want. 😜
@john.dough.
@john.dough. 2 месяца назад
10:14 -> For code snippets intended for language learners, it may help to not use font ligatures, so that people know what to type. In this case, the key ligatures "••" means ".." and "⟹" means "=>"
@john.dough.
@john.dough. 2 месяца назад
Great video though! Super helpful! :]
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you. :) Yea, I'll definitely change the font next time. Great feedback!
@Seacrest.
@Seacrest. 2 месяца назад
love that amount of creators about Rust grows here
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Rust is just worth it. Such a beautiful language! ☺️
@CuriousSpy
@CuriousSpy 2 месяца назад
You can write From btw
@kaziibrahimkhalil1011
@kaziibrahimkhalil1011 2 месяца назад
Beautifully explained. Everytime u publish a video my heart goes... Yayy a complete tutorial on rust🎉...but not😢...I can not explain how good i feel working with u...keep up ur good work and heart❤😋❤. Thanks for ur contribution.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you ☺️
@joeymea
@joeymea 2 месяца назад
Hey man, thanks for taking the time to make this! Rust is definitely lacking in short, advanced topical videos like this. I already knew of the Into trick, but I had never heard of the others! Bonus points for showing usage examples because theory isn't quite enough to get through my thick skull!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! Oh, and don't forget, you can always do more than only Into! ☺️💛
@equu497
@equu497 2 месяца назад
You know man, I've been trying and trying and trying to learn traits and why I need them for a loooong time now. Always found ways around it but I'm glad I came across your video, it helped more than I can express. Id love to see more from you
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Super happy to read that, man! 💛 My next video might have a few more reasons for you then. Still working on it, but I think it will teach you a few more things. ☺️
@abdo_omareg
@abdo_omareg 2 месяца назад
Another great video, very educational with lots of examples and straight to the point.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! 💛🙏🏻 Glad you like it!
@Proprogrammer001
@Proprogrammer001 2 месяца назад
Absolutely brilliant video. So many concepts are now clear now
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Super happy to hear that!
@luiscarlosjayk
@luiscarlosjayk 2 дня назад
Very useful! Thanks
@meowsqueak
@meowsqueak 2 месяца назад
Nice video - thanks, I learned something, and your explanation style is very good. For what it's worth, I think the frequent sound effects are cute at first, but become highly distracting and in at least one case genuinely alarming. Maybe they should be a lot quieter, and/or have some subtle variation to make them less jarring?
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you for this feedback. I'll experiment with the sound a little more in my next video and see whether I can blend it more in. 🙏🏻
@anneallison6402
@anneallison6402 2 месяца назад
Very good explanation!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thanks a lot! 💛🙌🏻
@sypher4912
@sypher4912 2 месяца назад
Very nice explanation!!!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you. Glad you liked it! 💛
@MaiklPolk
@MaiklPolk 2 месяца назад
Great video, thank you!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you for taking your time to watch it! 💛
@deryilz
@deryilz 2 месяца назад
great! 3:00 is my favorite part of the rust std lib
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Rust's std is incredible as a whole! 💛 Not much bs, the minimum required, but the best quality possible. ☺️
@WhiteSponge
@WhiteSponge 2 месяца назад
Really good video! subscribed!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! 💛🙏🏻
@RiwenX
@RiwenX 2 месяца назад
Thanks, I really needed this video as a refresher of my dormant knowledge
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Super happy to hear that. Thanks a lot for watching! 💛
@SomethingSomething1337
@SomethingSomething1337 2 месяца назад
this is so clear now! thank you!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Hey, super happy you find it useful! 💛
@polanas1879
@polanas1879 2 месяца назад
That's just top tier Rust content
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! 💛🙌🏻
@cthutu
@cthutu 2 месяца назад
Excellent video and great presentation of some fundamental concepts in Rust.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you very much! Super happy to read that you liked it. It really means a lot to me! 💛
@avalagum7957
@avalagum7957 2 месяца назад
Thank you very much. I just subscribed to your channel. Hope to have more videos like this from you. Thanks again.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Hey, thanks a lot! You can count on me creating many more videos ☺️ Already working on the next!
@leifelliott1500
@leifelliott1500 2 месяца назад
nice vid 👍
@TooFatToKidnap
@TooFatToKidnap 2 месяца назад
another banger video. keep up the good work Oliver 👍
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you very much! Already working on the next. Trying to improve every time. 💛🙏🏻
@mateocalvo6138
@mateocalvo6138 2 месяца назад
Using strings in factory methods I thought "there must be a better way to do this". I now know the way, thanks
@KylePrinsloo
@KylePrinsloo 2 месяца назад
I don't know Rust, but you covered it well and looks interesting :) thanks for the vid!
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you, Kyle! Oh, and congratulations on your new Podcast! Haven't had the time to watch it yet but it's the next on my list. 💛
@KylePrinsloo
@KylePrinsloo 2 месяца назад
@@oliverjumpertzme thanks man :)
@marcopaolovaleriovezzoli5776
@marcopaolovaleriovezzoli5776 2 месяца назад
Amazing and really important.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you very much! 💛🙏🏻
@OlegLecinsky
@OlegLecinsky 2 месяца назад
Could you add some explosions to those whoosh sounds and shake animations please? It just feels incomplete w/o explosions.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
More explosions, noted!
@emdeization
@emdeization 2 месяца назад
Good stuff
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! ❤️‍🔥🙏🏻
@1____-____1
@1____-____1 Месяц назад
Just so you know I was the 1000th sub. Congrats from a future Rustacean!
@oliverjumpertzme
@oliverjumpertzme Месяц назад
Wooohooooo! Thanks a lot! 💛🙌🏻
@helleye311
@helleye311 2 месяца назад
This is pretty good, thanks! I keep forgetting you can have the parameter as impl Into instead of just String. And then I'm annoyed when I constantly need to do .to_string() or .to_owned() or into() on my hardcoded text. Is there a difference between fn foo(s: impl Into) and fn foo(s: T) where T: Into whether that be something semantic or functional? Which is preferred for a simple example like this? Also I found you can do fn foo(s:T) and that gets translated to the where syntax. Good, bad, thoughts?
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Hey, thanks a lot!
@helleye311
@helleye311 2 месяца назад
​@@oliverjumpertzmeThat's great to know, thank you! I'm personally fond of putting the bound in the generic, but that's probably just because I'm primarily a typescript dev, and that's how typescript does it. Happy to know it's just "whatever you like" and not "well if you use where it's one behavior, and if you use impl it's another, and putting it in generic is the same as where but it implies something else". Hopefully there's a clippy rule to enforce using the same thing everywhere. I could get used to where or impl, but I would hate having all 3 scattered about the codebase if working with a team.
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
@@helleye311 definitely stick to it then! Feeling comfortable and ”at home” in your code is more important than any conventions. The old mantra: do what works best for you. That's the beauty of Rust. You are usually not penalized for doing it one or the other way. ☺️
@JorgetePanete
@JorgetePanete 2 месяца назад
8:14 HTTP/3 (HTTPS only) works over UDP/IP
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
That's true, but it only accounts for ~30% of internet traffic. http(s) and http2 still account for ~68% of all traffic. :)
@simonkalu
@simonkalu 2 месяца назад
Awesome
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
Thank you! 💛
@norude
@norude 2 месяца назад
Is there any way to make a conversion from MyStruct to a String? You can't `impl Into for MyStruct`, because a String is not From You can't `impl From for String`, because of orphan rules I am stuck
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
That's not entirely correct. :) If MyStruct is really YOUR struct, means, a local type (which is a type that you created and have under your control, read: its source is in one of your project's files), you can implement From for MyStruct as well as From for String. But I assume you mean that MyStruct is from a lib not under your control and now you want to implement From for either side? In that case, you can still work with the newtype principle. Create a new struct: struct Wrapper(ForeignType); and implement From for either side now, as Wrapper is now a local type, which means that orphan rules don't apply. :) An example: impl From for String { fn from(value: Wrapper) -> Self { // convert ForeignType to String } } Hope this helps?
@norude
@norude 2 месяца назад
​@@oliverjumpertzmeI understood now, I didn't have a proper understanding of the orphan rules. They state that if any of the type parameters is a local type, the impl is allowed. I assumed that since From and String are not local, the impl is not allowed
@inversebrah
@inversebrah 2 месяца назад
cool
@user-fe8hp6jv9f
@user-fe8hp6jv9f 2 месяца назад
Just started learning rust and I feel like I just leveled up lol
@oliverjumpertzme
@oliverjumpertzme 2 месяца назад
I guess that's a perfect start then!
Далее
How to fight Rust's borrow checker... and win.
8:29
Просмотров 36 тыс.
Why Rust is NOT a Passing Fad...
8:54
Просмотров 23 тыс.
How to Build & Deploy a Rust App in Under 60 Seconds
0:59
The Rust Standard Library is SO Confusing...Until Now!
11:45
Rust: Generics, Traits, Lifetimes
35:34
Просмотров 43 тыс.
Safe Rust AIN'T SAFE!? (cve-rs)
20:42
Просмотров 48 тыс.
Rust is easy... (we make it hard)
10:11
Просмотров 113 тыс.
Rust: When C Code Isn't Enough
8:26
Просмотров 150 тыс.
but what is 'a lifetime?
12:20
Просмотров 56 тыс.
Rust Data Modelling Without Classes
11:25
Просмотров 158 тыс.
Китайская зарядка❌НЕЛЬЗЯ
0:24