Rust Modules - Explained Like I'm 5

  Рет қаралды 73,351

Let's Get Rusty

Let's Get Rusty

Күн бұрын

Пікірлер: 195
@letsgetrusty
@letsgetrusty 2 жыл бұрын
📝 Get your FREE Rust cheat sheet : www.letsgetrusty.com/cheatsheet
@Xeros08
@Xeros08 2 жыл бұрын
I got mine, tho I don't like mailing lists too much :/
@LordOfWizardurl
@LordOfWizardurl 2 жыл бұрын
Loving the cheat sheet..i keep open on a tab always
@robicjedi
@robicjedi 2 жыл бұрын
indeed, I would have liked to checked it out, but don't want to sign up to anything
@PandaNuker
@PandaNuker 2 жыл бұрын
really love the cheatsheet! is there any chance a v2 is planned (simply a bit more readable / good looking / maybe dark themed?) Thanks for your videos! loving it
@dazealex
@dazealex Жыл бұрын
Hate the signup mailing list. So skipped the cheatsheet.
@scheimong
@scheimong 2 жыл бұрын
Honestly speaking this is probably the single most confusing aspect of Rust I faced, much more so than the whole ownership thing. I think it might be down to how little attention it was given in various Rust learning resources (Rust Book in particular). It took me several months of scratching my head and smushing my face into the screen, combined with extensive experimenting on my personal projects for me to fully understand the whole system, and you sir managed to do it under 20 minutes. God damn. Mad respect.
@gritcrit4385
@gritcrit4385 2 жыл бұрын
Yeah, same here.
@LucasVieira42
@LucasVieira42 2 жыл бұрын
This!!!!
@r3ddr4gon80
@r3ddr4gon80 2 жыл бұрын
Same :) This video is absolutely awesome!
@flogginga_dead_horse4022
@flogginga_dead_horse4022 2 жыл бұрын
me too!!
@daniilgumirov6654
@daniilgumirov6654 2 жыл бұрын
Thanks God I was able to find the video in only a week of smashing the face into the screen...
@----__---
@----__--- 2 жыл бұрын
I have read many blogs before getting the gist of the module system of rust. Actually the only thing I needed was this video lol
@ChumX100
@ChumX100 2 жыл бұрын
It's nice that you've kept the format of videos on fundamentals similar to your coverage of the rust book, it's like having an extended version!
@naughtrussel5787
@naughtrussel5787 2 жыл бұрын
Yeah, the modules did confuse me a lot. During this video I was thinking: "Oh, okay, now I finally get it. How great he explains it so clear." and then I remember that the video is actually called "Explained Like I'm 5". Now I feel I have to study programming as if I was five :-D
@hasansimsek1
@hasansimsek1 Ай бұрын
lol
@shirazbabar8892
@shirazbabar8892 Жыл бұрын
Oh, man, you saved me! I was about to give up and head back home because I was overwhelmed by the complexity of these modules. But then I stumbled upon you, and now I feel like I'm back in a playground, ready to tackle anything
@scott3489
@scott3489 2 жыл бұрын
Excellent video! Really appreciate how you broke this down.
@michaelkastner3611
@michaelkastner3611 Жыл бұрын
This is by far the best explanation of Rust module system I've seen (or read) so far. Very thoroughly explained. I've reentered the Rust orbit after almost two years again and had forgotten about the intricacies of the Rust module concept in the mean time. Now I feel like I am back on track again. This video is pure gold. Thanks!
@stevemccauley
@stevemccauley Жыл бұрын
A great video, that's cleared the a major point of confusion up for me. It's like 'use' has been overridden, like 'static' in C - for external module use, it's 'importing' and 'simplifying' external crate components, whereas for local modules it's merely 'simplifying' part of the local module. So subtly different actions, but with the same name. You've clarified that for me, so thanks!
@seyeakintunde8225
@seyeakintunde8225 2 жыл бұрын
I was reading Chapter 7 of the Rust Book and found the example a little confusing so I searched for an alternative source of information abuot modules in Rust. This was just what I needed. Thank a lot Rusty!!!
@jonathanmoore5619
@jonathanmoore5619 2 жыл бұрын
Perfect screen size / text. Great video.
@hilsonalexandrejuniorwojci9028
@hilsonalexandrejuniorwojci9028 2 жыл бұрын
Thank you. I think that this video is much more informative than the module episode of the rust book series and the chapter of the rust book itself!! I was bugged thinking about a module not "export itself" but being declared in the parent module
@emcell2
@emcell2 Жыл бұрын
God, thank you. I was so confused about modules. Having read dozens of documents about this topic getting even more confused. Now everything makes sense.
@Mirusim
@Mirusim 2 жыл бұрын
As a JS developer I need more videos like this. Thanks
@mingyuchoo
@mingyuchoo Жыл бұрын
You made these easy for me to understand. Now I understand how Rust's module system works. thank you.
@errons1
@errons1 2 жыл бұрын
Many might already have said this, but this was the achilles heel of my rust experience so far... Thank you very much for making this video!
@student99bg
@student99bg Жыл бұрын
This is the best explanation that I have found so far. Rust modules were a little bit confusing because they work differently from how organisation of code world in other languages.
@godoftheLTD
@godoftheLTD 2 жыл бұрын
THANK YOU for this! Modules finally clicked for me! Request: a similar video (or videos) breaking down Cargo crates. For example, crates with multiple binaries and projects with nested Cargo configs.
@dimiutube
@dimiutube 9 ай бұрын
The best explanation about Rust´s module system I got! This is all really confusing, but now it seems to make some sense 😊 Thank you!
@scheimong
@scheimong 2 жыл бұрын
I bet this will be your most popular video in 5 years time. Graet job.
@letsgetrusty
@letsgetrusty 2 жыл бұрын
Thank you!
@ravipasumarthy8732
@ravipasumarthy8732 Жыл бұрын
Kindly cover some (design) patterns in how to export rust functions to swift and kotlin via FFI. Thank you, your video on rust modules is very helpful.
@farzadmf
@farzadmf 2 жыл бұрын
AMAZING explanation and step-by-step tutorial, thank you!
@quertyv12
@quertyv12 2 жыл бұрын
👍Great job! I'd like to learn more about benchmarking/profiling of Rust code. Another thing that is confusing is why we need to write anon lifetime specifier _ (underline) . I see it in very often in trait/struct decl/def.
@RakavyYuval
@RakavyYuval 2 жыл бұрын
It would be nice if you cover cross development and debugging for the Raspberry Pi and it would also be nice to cover using Rust for embedded systems (no runtime), for example on Arduino.
@islamibrahim8121
@islamibrahim8121 2 жыл бұрын
Hi! Please include this video in the let's get rusty tutorial series. It's really helpful in visualizing the module system, especially the refactoring approach you took. And exploring the 2018 pattern (came across this in the wild and I was quite confused )
@kevincarvalhodejesus4473
@kevincarvalhodejesus4473 Жыл бұрын
That's precisely what i needed, a simple, concise and comprehensive explanation. Now i got it, thanks a lot!
@malnek12
@malnek12 Жыл бұрын
Thank you for this quick explanation, much appreciated.
@dagoberttrump9290
@dagoberttrump9290 4 ай бұрын
Really nice well rounded and concise presentation, thanks!
@AK-vx4dy
@AK-vx4dy Жыл бұрын
Very good explanation! Modules should be explaind again and again beacuse they are vital part of rust encapsulation approach.
@Reydriel
@Reydriel 3 ай бұрын
Good stuff. The chapter in the Rust book needs this sort of example-based explanation as well as comparisons to other languages lol
@sebastianconcept
@sebastianconcept 2 жыл бұрын
Okay, convoluted conventions but once understood they make sense and feel clean and powerful enough to maintain code properly factored and under control. Thanks a lot for making this video, it was a day saver!
@sagnikbhattacharya1202
@sagnikbhattacharya1202 2 жыл бұрын
Very very very useful!!! Next could you please cover conditional compilation, build flags, build.rs, etc.? Thanks a lot
@mjk6035
@mjk6035 Жыл бұрын
Great video that helps a lot in understanding the concept of modules in Rust
@delir0
@delir0 Жыл бұрын
One of the most important and useful videos in Rust learning. Many thanks!
@ykhi
@ykhi Жыл бұрын
This is such a helpful channel whenever I try to learn a bit more about rust thank you!
@pygeekrfoo820
@pygeekrfoo820 Жыл бұрын
This is such impressive teaching. Good job.
@gabonesmith4750
@gabonesmith4750 10 ай бұрын
clear and concise explanation
@jhoughjr1
@jhoughjr1 Жыл бұрын
It seems in 2023, you need to run " cargo modules --with-types --with-fns " to get the same output as shown in the video. Went on a detour trying to see why my output differed and that was the result.
@rootkill1581
@rootkill1581 2 жыл бұрын
Rust Made Easy with Let's Get Rusty! you made it really easy to understand!
@therealmattplayer
@therealmattplayer 2 жыл бұрын
Perfectly explained, cheers.
@InMemoryOfNeo
@InMemoryOfNeo Жыл бұрын
awesome video. this is what I want to know. there are some minor differences then javascript but rust's module system is more effective and sense I think.
@jamiehagerty6732
@jamiehagerty6732 2 жыл бұрын
Amazing Video. Out of so many I've watched on this topic, this is the one that made everything click for me. Thank you
@tr3ysmith
@tr3ysmith 2 жыл бұрын
It would be awesome if you did some videos on async/await
@letsgetrusty
@letsgetrusty 2 жыл бұрын
On the list!
@dedenapraia
@dedenapraia 2 жыл бұрын
Finally ! Bogdan thank you for this. Rust Yedi !
@ari-mcbrown
@ari-mcbrown 2 жыл бұрын
omg, I couldn't put my finger on it... You're right. He's the chosen one. ;)
@fallout__boy1130
@fallout__boy1130 Жыл бұрын
Thank you so much for this great content, this is very valuable for me!
@nilshaberstroh2705
@nilshaberstroh2705 2 жыл бұрын
I've googled "ho to use modules in Rust" so so many time. It is a pleasure to see such a useful, straight forward explanation on that topic. loop { 👍}
@Ryggis
@Ryggis 2 жыл бұрын
This concept is really easy to understand on small projects, but I would still love to see a bigger project example
@winter_light
@winter_light 2 жыл бұрын
I did not understand the last part about exporting credentials. Rest of the section were 🔥
@danielstonebuilt1265
@danielstonebuilt1265 11 ай бұрын
Explained like you were Grandma: thank you granda 😁
@ClearerThanMud
@ClearerThanMud 2 жыл бұрын
Nice job. In IntelliJ I find it convenient to just create modules in line and then tell IntelliJ to turn them into separate files.
@raizul9978
@raizul9978 2 жыл бұрын
Man I wished this video existed before I struggled to make sense of modules.
@connorzittrauer3306
@connorzittrauer3306 Жыл бұрын
thank you, very well explained!
@liunox6023
@liunox6023 2 жыл бұрын
thanks man, this is really great video.
@alfredomenezes8814
@alfredomenezes8814 2 жыл бұрын
Amazing, thank you very much!
@bobschaaf2549
@bobschaaf2549 2 жыл бұрын
What's missing is a way of splitting a module's source over multiple files while still maintaining a flat namespace.
@yinkao_
@yinkao_ Жыл бұрын
Thank you so much for this!
@bjugdbjk
@bjugdbjk 2 жыл бұрын
Could u make a video sharing abt professional exp and y u r moving to RUST !!
@freshlix9554
@freshlix9554 Жыл бұрын
Now that I think of it, is there a VSC extension/configuration for sorting and files in the tree regardless of their type? In order to group the modules with their sub-modules..
@LordOfWizardurl
@LordOfWizardurl 2 жыл бұрын
Please make a video on Emacs + Rust
@amitp277
@amitp277 2 жыл бұрын
Awesome.
@Gruby7C1h
@Gruby7C1h 11 ай бұрын
With my version of cargo modules it's: "cargo modules generate tree --types"
@spongechameleon6940
@spongechameleon6940 2 жыл бұрын
So the only things crate consumers can use from a crate are items in the crate module marked pub? The items marked pub in sub-modules are only pub for the crate module, and need to be explicitly "re-pub'd" from the crate module to also be made available to the crate consumer?
@PhosphorusMoscu-code
@PhosphorusMoscu-code 2 жыл бұрын
You explications are very good! Thanks for aclarate this topic.
@flogginga_dead_horse4022
@flogginga_dead_horse4022 2 жыл бұрын
Your videos are Rust gold :P
@Only-zeus
@Only-zeus 2 жыл бұрын
Happy new year bro cheers!! 🍻
@letsgetrusty
@letsgetrusty 2 жыл бұрын
Happy new year!
@rpxdytx
@rpxdytx 2 жыл бұрын
I just love how `cargo install cargo-modules` says "Downloading 4 crates" and then it says "Building [] 1/226 crate"
@M-Daeva
@M-Daeva 2 жыл бұрын
2:31 How to setup VSCode to move automatically text cursor with indentation after pressing enter inside curve brackets? Is it rust-analyzer settings option?
@bencekeomley-horvath385
@bencekeomley-horvath385 10 ай бұрын
Still it doesn't expain how can I add even more directory depth to it. I'm experienced C++, GO, Python developer, even after this video I have no idea how to structure my code
@ryandsouza2962
@ryandsouza2962 Жыл бұрын
Would one recommend this same structure used for libraries in applications as well?
@recklessroges
@recklessroges 2 жыл бұрын
Really well explained. (Even I understood it.)
@erlangparasu6339
@erlangparasu6339 2 жыл бұрын
Great tutorial 👍 Thank you so much 🙏
@migom6
@migom6 2 жыл бұрын
Let's get rusty with futures and async ?
@x1expert1x
@x1expert1x Жыл бұрын
the "if let Status::Connected" line prevents me from compiling your code, "error[E0658]: `let...else` statements are unstable"
@singhsaubhik
@singhsaubhik 2 жыл бұрын
Thanks for this awesome video. Net video that I would request you to cover is `error handling` may be using thiserror and anyhow.
@MrYevelnad
@MrYevelnad 2 жыл бұрын
I kinda stuck on a problem where I can't make traits use the pub keyword when they are inside a module (so kinda want to use inheritance as to what i have learned in php). Like the animal human example in rust where traits are implemented. But seems like my approach is kinda wrong. I happen to watch the video about builder pattern and it seems pretty much "fixed" my problem. It pretty much avoid you of having creating a struct that only one value is different but almost have the same methods.
@theprantadutta
@theprantadutta 7 ай бұрын
you literally explained like I'm 5, I mean like I have 5 years of programming experience.
@hnazmul
@hnazmul Жыл бұрын
hey, I have installed cargo modules. but when I run the command as like your command. its not showing me similar result to your. it just show mod and struct and enum. what the problem here.
@proudmoroccan8164
@proudmoroccan8164 2 жыл бұрын
Great stuff, thank you sharing.
@dubfather521
@dubfather521 Ай бұрын
I finally understand
@sayantanchakrabarty1857
@sayantanchakrabarty1857 11 ай бұрын
Hey , I the cargo modules "generate tree --with-types" is not working. I have tried it by "generate tree --no-types" though its not showing as per the result in the video. Anyone help ?
@jnkconsultbv8274
@jnkconsultbv8274 2 жыл бұрын
Many thanks
@Shifticek
@Shifticek Жыл бұрын
why does installing cargo-modules need 250 other crates?
@nightfall2863
@nightfall2863 6 ай бұрын
why is it like this tho is there a good reason to have it designed like this? why not be bound by folder path?
@FrederickAlvarez_
@FrederickAlvarez_ Жыл бұрын
I saw some of your videos and then I found thta I wasn't subscribed, just did awesome content
@jonathanmoore5619
@jonathanmoore5619 2 жыл бұрын
I'm a bit confused with re export. In a nutshell does it mean making nested modules functions, structs etc... within your project src public for use at the top level, so anyone can use the function? Like a public interface?
@marcopiovesan9153
@marcopiovesan9153 Жыл бұрын
Despite your excellent video I was going crazy exposing a function then I discovered that starting from version 0.7.0 of cargo-modules "The --with-types now excludes functions. Use --with-fns CLI option to include functions"
@nezman_x2080
@nezman_x2080 6 ай бұрын
for me cargo modules generate tree didnt wor even after installing!
@BhupalKohar
@BhupalKohar 7 ай бұрын
when I am trying to run cargo modules generate tree command then shows this PS C:\Rust\practicse> cargo modules generate tree error: unexpected argument 'generate' found Usage: cargo-modules.exe
@markmathman
@markmathman 2 жыл бұрын
Great video. But I am still confused. I want the rust equivalent to the following code from C++. // file: main.c void ace(); int main() { ace(); return 0;} // file: a.c void bar(); void ace() { bar();} // file: b.c void bar() { std::cout
@quevinquinvulafrancisco2653
@quevinquinvulafrancisco2653 Ай бұрын
does that only work for lib?
@Robin-ws9fg
@Robin-ws9fg 2 жыл бұрын
Awesome content, please cover serde/serde-json ! :)
@letsgetrusty
@letsgetrusty 2 жыл бұрын
Thanks! Will do!
@happymt5735
@happymt5735 2 жыл бұрын
很棒的视频,学习了
@thirdreplicator
@thirdreplicator 2 жыл бұрын
How do you use your library within main.rs?
@Pjiwm
@Pjiwm 2 жыл бұрын
Okay but let's say we have another sub directory next to auth_utils, and we want to make use of auth_utils from inside that directory. In Iib.rs we could just use mod auth_utils to make use of its sub modules and functions. How would this work inside a file in a neighboring subdirectory?
@JitenPalaparthi
@JitenPalaparthi Жыл бұрын
Good stuff
@leahwaymire2715
@leahwaymire2715 3 ай бұрын
what vscode extensions do you use?
@gamer-gw9iy
@gamer-gw9iy 2 жыл бұрын
Did you make your website with rust?
@kaiblade760
@kaiblade760 2 жыл бұрын
I do understand it. Most 5 year old won't understand it though
@liberalwrecker949
@liberalwrecker949 Жыл бұрын
So namespaces with extra steps
@danielmilyutin9914
@danielmilyutin9914 2 жыл бұрын
Hi I'm new to Rust. And I had a struggle with extracting struct S and its 'impl new' to other file. Rust just don't see S::new(). I have no idea why 😅
Strings in Rust FINALLY EXPLAINED!
21:40
Let's Get Rusty
Рет қаралды 76 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 310 М.
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 116 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 238 МЛН
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 4,8 МЛН
Linus On LLMs For Coding
17:06
ThePrimeTime
Рет қаралды 275 М.
why rust libraries may never exist.
7:26
Low Level
Рет қаралды 257 М.
Rust Functions and Modules 🦀
21:55
Trevor Sullivan
Рет қаралды 9 М.
Rust keeps making JavaScript faster
5:16
Let's Get Rusty
Рет қаралды 94 М.
RUST Enums ARE Better
5:49
ThePrimeagen
Рет қаралды 142 М.
Rust Lifetimes Finally Explained!
19:10
Let's Get Rusty
Рет қаралды 158 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 146 М.
Rust's Witchcraft
9:18
No Boilerplate
Рет қаралды 180 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level
Рет қаралды 357 М.
Why do developers hate Rust?
8:20
Let's Get Rusty
Рет қаралды 123 М.
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 116 МЛН