Rust Modules - Explained Like I'm 5

Ғылым және технология

Today we are learning about modules in the Rust programming language by going through a code example!
📝 Get your FREE Rust cheat sheet: www.letsgetrusty.com/cheatsheet
Chapters:
0:00 Intro
0:45 High-Level Explanation
1:34 Code Example
4:33 Adding Inline Modules
13:49 Moving Modules to Different Files
19:29 Outro
#letsgetrusty​​ #rust​lang​ #tutorial

Пікірлер: 190

  • @letsgetrusty
    @letsgetrusty2 жыл бұрын

    📝 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
    @scheimong2 жыл бұрын

    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
    @ChumX1002 жыл бұрын

    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
    @naughtrussel57872 жыл бұрын

    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

  • @shirazbabar8892
    @shirazbabar889211 ай бұрын

    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
    @scott34892 жыл бұрын

    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!

  • @nilshaberstroh2705
    @nilshaberstroh27052 жыл бұрын

    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 { 👍}

  • @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!

  • @jonathanmoore5619
    @jonathanmoore56192 жыл бұрын

    Perfect screen size / text. Great video.

  • @seyeakintunde8225
    @seyeakintunde8225 Жыл бұрын

    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!!!

  • @hilsonalexandrejuniorwojci9028
    @hilsonalexandrejuniorwojci90282 жыл бұрын

    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

  • @andydataguy
    @andydataguy2 жыл бұрын

    You're a legend. Learning Rust as my first coding language and am going to binge watch your videos to help accelerate the process. Thank you so much for taking the time to put these videos together 🙌🏾🙏🏾🔥

  • @Helvanic

    @Helvanic

    2 жыл бұрын

    Rust is not the easiest way to learn coding, but it will certainly help you in the long run. Good luck !

  • @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.

  • @mingyuchoo
    @mingyuchoo11 ай бұрын

    You made these easy for me to understand. Now I understand how Rust's module system works. thank you.

  • @Mirusim
    @Mirusim2 жыл бұрын

    As a JS developer I need more videos like this. Thanks

  • @soma_rc
    @soma_rc Жыл бұрын

    Wathed 3 tuturials. This one clearly stands out! 👍

  • @errons1
    @errons1 Жыл бұрын

    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!

  • @AK-vx4dy
    @AK-vx4dy10 ай бұрын

    Very good explanation! Modules should be explaind again and again beacuse they are vital part of rust encapsulation approach.

  • @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.

  • @dimiutube
    @dimiutube6 ай бұрын

    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!

  • @farzadmf
    @farzadmf2 жыл бұрын

    AMAZING explanation and step-by-step tutorial, thank you!

  • @sunitjoshi3573
    @sunitjoshi35735 ай бұрын

    Nice and detailed explanation of a confusing subject in Rust! I'll still have to play around a bit...but this was really insightful !

  • @godoftheLTD
    @godoftheLTD2 жыл бұрын

    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.

  • @mikecu2249
    @mikecu22499 ай бұрын

    HOLY COW , this is TEH hands down best explenation on the net for Rust Newcommers! This Explains Use vs Mod perfect! Thank you so much!

  • @dagoberttrump9290
    @dagoberttrump9290Ай бұрын

    Really nice well rounded and concise presentation, thanks!

  • @henrikdjurestal6947
    @henrikdjurestal69472 жыл бұрын

    Excellent pace of the video. These videos are perfect as I try to learn and start using Rust!

  • @delir0
    @delir011 ай бұрын

    One of the most important and useful videos in Rust learning. Many thanks!

  • @malnek12
    @malnek12 Жыл бұрын

    Thank you for this quick explanation, much appreciated.

  • @Anonim27121996
    @Anonim271219962 жыл бұрын

    Your explaination was perfect! Great job

  • @kevincarvalhodejesus4473
    @kevincarvalhodejesus4473 Жыл бұрын

    That's precisely what i needed, a simple, concise and comprehensive explanation. Now i got it, thanks a lot!

  • @cjmeyer429
    @cjmeyer4292 жыл бұрын

    Great topic! Took something that can be difficult to understand and presented it in a simple step by step presentation! My favorite!

  • @quertyv12
    @quertyv122 жыл бұрын

    👍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.

  • @scheimong
    @scheimong2 жыл бұрын

    I bet this will be your most popular video in 5 years time. Graet job.

  • @letsgetrusty

    @letsgetrusty

    2 жыл бұрын

    Thank you!

  • @islamibrahim8121
    @islamibrahim81212 жыл бұрын

    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 )

  • @jamiehagerty6732
    @jamiehagerty67322 жыл бұрын

    Amazing Video. Out of so many I've watched on this topic, this is the one that made everything click for me. Thank you

  • @kumaraguru.m6205
    @kumaraguru.m62052 ай бұрын

    Awesome , Clear understanding ❤ Thanks for this video 🎉

  • @WolfeyGamedev
    @WolfeyGamedev Жыл бұрын

    Well done. This is exactly what I needed!

  • @ykhi
    @ykhi Жыл бұрын

    This is such a helpful channel whenever I try to learn a bit more about rust thank you!

  • @Reydriel
    @Reydriel15 күн бұрын

    Good stuff. The chapter in the Rust book needs this sort of example-based explanation as well as comparisons to other languages lol

  • @RakavyYuval
    @RakavyYuval2 жыл бұрын

    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.

  • @sederonveyll8409
    @sederonveyll840911 ай бұрын

    Great video and channel in general, you answered all my questions i had.

  • @drlytwatcher2646
    @drlytwatcher26462 жыл бұрын

    Really well described! I'd love if you could make a video about async/await as well as how it differs from its implementation in more popular languages like Javascript. This topic has always been tricky to wrap my head around. I think a lot of viewers would benefit from a solid explanation LGR style :)

  • @ukaszferenc5249
    @ukaszferenc5249 Жыл бұрын

    I am getting into programming and learning Rust, I think it's pleasantly elegant!

  • @gabonesmith4750
    @gabonesmith47507 ай бұрын

    clear and concise explanation

  • @harrymiller7559
    @harrymiller75592 жыл бұрын

    cool - now I am able to structure my code into models. Thank you. It would be fine to learn something about testing in Rust.

  • @therealmattplayer
    @therealmattplayer Жыл бұрын

    Perfectly explained, cheers.

  • @pygeekrfoo820
    @pygeekrfoo82011 ай бұрын

    This is such impressive teaching. Good job.

  • @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.

  • @emmanuelelegbede2812
    @emmanuelelegbede2812 Жыл бұрын

    Amazing. this was really helpful and concise

  • @mjk6035
    @mjk6035 Жыл бұрын

    Great video that helps a lot in understanding the concept of modules in Rust

  • @sagnikbhattacharya1202
    @sagnikbhattacharya12022 жыл бұрын

    Very very very useful!!! Next could you please cover conditional compilation, build flags, build.rs, etc.? Thanks a lot

  • @tim4857
    @tim48572 жыл бұрын

    Nice video! Now I finally understand the Rust modules and project structure. As there are 2 approaches mentioned in this video to struct the modules and project files, may I know which one approach is more popular or is most used in the practice? Thanks a lot!

  • @relaxsightme
    @relaxsightme2 жыл бұрын

    bro, your video is so good. I have know the concept of rust modules. Thanks very much.

  • @sebastianconcept
    @sebastianconcept2 жыл бұрын

    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!

  • @erlangparasu6339
    @erlangparasu63392 жыл бұрын

    Great tutorial 👍 Thank you so much 🙏

  • @LuisMarinAguilera
    @LuisMarinAguilera2 жыл бұрын

    This video is pure gold!

  • @yinkao_
    @yinkao_ Жыл бұрын

    Thank you so much for this!

  • @connorzittrauer3306
    @connorzittrauer3306 Жыл бұрын

    thank you, very well explained!

  • @qwertgfhxc
    @qwertgfhxc2 ай бұрын

    great explanation, thanks a lot!

  • @liunox6023
    @liunox6023 Жыл бұрын

    thanks man, this is really great video.

  • @danielstonebuilt1265
    @danielstonebuilt12658 ай бұрын

    Explained like you were Grandma: thank you granda 😁

  • @fallout__boy1130
    @fallout__boy11309 ай бұрын

    Thank you so much for this great content, this is very valuable for me!

  • @alfredomenezes8814
    @alfredomenezes88142 жыл бұрын

    Amazing, thank you very much!

  • @rootkill1581
    @rootkill15812 жыл бұрын

    Rust Made Easy with Let's Get Rusty! you made it really easy to understand!

  • @proudmoroccan8164
    @proudmoroccan81642 жыл бұрын

    Great stuff, thank you sharing.

  • @andrefilipefonsecaborba4989
    @andrefilipefonsecaborba4989 Жыл бұрын

    What's up rusty! everything fine? Came here to complete one more monster video about Rust! Thank you for sharing your knownledges with us. RUST ❤

  • @yapayzeka
    @yapayzeka2 жыл бұрын

    best rust channel out there

  • @marcocaspers3136
    @marcocaspers31369 ай бұрын

    If you try this today, you need to install cargo-modules using this command: cargo install cargo-modules --locked. It won't work any other way. It needs to install a million things and some of those things don't play nice together dependency wise. Also, the command to use to generate the try with types is now: cargo modules generate tree --types, The author(s) of cargo-modules have seemingly introduced several feature breaking changes on top of creating the dependancy nightmare that makes dll hell pale in comparison.

  • @kqvanity

    @kqvanity

    Ай бұрын

    It did install for me without appending the --locked flag, but the subcommands are totally different

  • @Ryggis
    @Ryggis2 жыл бұрын

    This concept is really easy to understand on small projects, but I would still love to see a bigger project example

  • @dedenapraia
    @dedenapraia2 жыл бұрын

    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. ;)

  • @PhosphorusMoscu-code
    @PhosphorusMoscu-code2 жыл бұрын

    You explications are very good! Thanks for aclarate this topic.

  • @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.

  • @hasiburrahman1461
    @hasiburrahman14617 ай бұрын

    It was Awesome bro!

  • @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.

  • @Only-zeus
    @Only-zeus2 жыл бұрын

    Happy new year bro cheers!! 🍻

  • @letsgetrusty

    @letsgetrusty

    2 жыл бұрын

    Happy new year!

  • @tr3ysmith
    @tr3ysmith2 жыл бұрын

    It would be awesome if you did some videos on async/await

  • @letsgetrusty

    @letsgetrusty

    2 жыл бұрын

    On the list!

  • @amitp277
    @amitp2772 жыл бұрын

    Awesome.

  • @glener1000
    @glener10004 ай бұрын

    In my project, when I added more folder branches within 'src', the local code worked normally (build, fmt, test). But when I executed the same in the CI/CD process, it was as if I couldn't find the imports in that format...

  • @DooMWhite
    @DooMWhite2 жыл бұрын

    Amazing!

  • @ClearerThanMud
    @ClearerThanMud2 жыл бұрын

    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
    @raizul99782 жыл бұрын

    Man I wished this video existed before I struggled to make sense of modules.

  • @moaazk1936
    @moaazk193622 күн бұрын

    Great tutorials. Can you list down or make a video on which extensions do you use in VSCode for Rust. Many thanks in advance

  • @recklessroges
    @recklessroges2 жыл бұрын

    Really well explained. (Even I understood it.)

  • @fatemeetsluck
    @fatemeetsluck Жыл бұрын

    This was much easier to understand than the official book.

  • @KoboldAdvocate

    @KoboldAdvocate

    Жыл бұрын

    Seeing someone do it while talking through it is a big help.

  • @jnkconsultbv8274
    @jnkconsultbv82742 жыл бұрын

    Many thanks

  • @singhsaubhik
    @singhsaubhik2 жыл бұрын

    Thanks for this awesome video. Net video that I would request you to cover is `error handling` may be using thiserror and anyhow.

  • @JitenPalaparthi
    @JitenPalaparthi11 ай бұрын

    Good stuff

  • @happymt5735
    @happymt57352 жыл бұрын

    很棒的视频,学习了

  • @michaelpacheco7421
    @michaelpacheco74212 жыл бұрын

    FINALLY I GOT IT!

  • @freshlix9554
    @freshlix955411 ай бұрын

    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..

  • @winter_light
    @winter_light2 жыл бұрын

    I did not understand the last part about exporting credentials. Rest of the section were 🔥

  • @ryandsouza2962
    @ryandsouza296210 ай бұрын

    Would one recommend this same structure used for libraries in applications as well?

  • @flogginga_dead_horse4022
    @flogginga_dead_horse40222 жыл бұрын

    Your videos are Rust gold :P

  • @LordOfWizardurl
    @LordOfWizardurl2 жыл бұрын

    Please make a video on Emacs + Rust

  • @jonathanmoore5619
    @jonathanmoore56192 жыл бұрын

    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?

  • @TheBest-sd2qf
    @TheBest-sd2qf2 жыл бұрын

    Something I often wonder about, does it speed up compile time if you split up your project in multiple modules?

  • @bobschaaf2549
    @bobschaaf25492 жыл бұрын

    What's missing is a way of splitting a module's source over multiple files while still maintaining a flat namespace.

  • @bjugdbjk
    @bjugdbjk2 жыл бұрын

    Could u make a video sharing abt professional exp and y u r moving to RUST !!