Rust Modules - Explained Like I'm 5

Поділитися
Вставка
  • Опубліковано 4 лют 2025

КОМЕНТАРІ • 207

  • @letsgetrusty
    @letsgetrusty  3 роки тому +14

    📝 Get your FREE Rust cheat sheet : www.letsgetrusty.com/cheatsheet

    • @Xeros08
      @Xeros08 3 роки тому +2

      I got mine, tho I don't like mailing lists too much :/

    • @LordOfWizardurl
      @LordOfWizardurl 3 роки тому

      Loving the cheat sheet..i keep open on a tab always

    • @robicjedi
      @robicjedi 3 роки тому

      indeed, I would have liked to checked it out, but don't want to sign up to anything

    • @PandaNuker
      @PandaNuker 3 роки тому +1

      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 2 роки тому

      Hate the signup mailing list. So skipped the cheatsheet.

  • @scheimong
    @scheimong 3 роки тому +257

    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.

  • @----__---
    @----__--- 3 роки тому +43

    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 3 роки тому +55

    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!

  • @shirazbabar8892
    @shirazbabar8892 Рік тому +5

    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

  • @michaelkastner3611
    @michaelkastner3611 2 роки тому +5

    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
    @nilshaberstroh2705 3 роки тому +5

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

  • @scott3489
    @scott3489 3 роки тому +37

    Excellent video! Really appreciate how you broke this down.

  • @stevemccauley
    @stevemccauley 2 роки тому +2

    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!

  • @naughtrussel5787
    @naughtrussel5787 3 роки тому +23

    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

  • @emcell2
    @emcell2 2 роки тому +1

    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.

  • @hilsonalexandrejuniorwojci9028
    @hilsonalexandrejuniorwojci9028 2 роки тому +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

  • @jonathanmoore5619
    @jonathanmoore5619 3 роки тому +6

    Perfect screen size / text. Great video.

  • @mingyuchoo
    @mingyuchoo Рік тому +1

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

  • @andydataguy
    @andydataguy 3 роки тому +7

    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 роки тому +7

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

  • @soma_rc
    @soma_rc Рік тому +1

    Wathed 3 tuturials. This one clearly stands out! 👍

  • @seyeakintunde8225
    @seyeakintunde8225 2 роки тому +5

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

  • @sunitjoshi3573
    @sunitjoshi3573 Рік тому +1

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

  • @errons1
    @errons1 2 роки тому +1

    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!

  • @DipsAndPushups
    @DipsAndPushups 2 роки тому +1

    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.

  • @joaopedrorocha5693
    @joaopedrorocha5693 3 місяці тому

    you've got a subscriber! exactly what i needed! was with that strange feeling you've mentioned while reading The Book, now it feels clear.

  • @Mirusim
    @Mirusim 3 роки тому +9

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

  • @henrikdjurestal6947
    @henrikdjurestal6947 2 роки тому +1

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

  • @godoftheLTD
    @godoftheLTD 3 роки тому +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 Рік тому

    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!

  • @kevincarvalhodejesus4473
    @kevincarvalhodejesus4473 Рік тому

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

  • @spongechameleon6940
    @spongechameleon6940 2 роки тому +1

    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?

  • @AK-vx4dy
    @AK-vx4dy Рік тому +1

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

  • @cmkjfnve
    @cmkjfnve 3 роки тому +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.

  • @scheimong
    @scheimong 3 роки тому +2

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

  • @farzadmf
    @farzadmf 3 роки тому +3

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

  • @Anonim27121996
    @Anonim27121996 2 роки тому +1

    Your explaination was perfect! Great job

  • @delir0
    @delir0 Рік тому

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

  • @mikecu2249
    @mikecu2249 Рік тому

    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!

  • @InMemoryOfNeo
    @InMemoryOfNeo Рік тому +1

    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.

  • @kim4857-u7j
    @kim4857-u7j 2 роки тому +1

    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!

  • @malnek12
    @malnek12 Рік тому

    Thank you for this quick explanation, much appreciated.

  • @ykhi
    @ykhi 2 роки тому

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

  • @dagoberttrump9290
    @dagoberttrump9290 8 місяців тому

    Really nice well rounded and concise presentation, thanks!

  • @islamibrahim8121
    @islamibrahim8121 2 роки тому +1

    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 )

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

  • @superfortekiai
    @superfortekiai Місяць тому

    Well explained, the best rust youtube channel.

  • @ravipasumarthy8732
    @ravipasumarthy8732 2 роки тому +1

    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.

  • @ukaszferenc5249
    @ukaszferenc5249 2 роки тому

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

  • @sederonveyll8409
    @sederonveyll8409 Рік тому

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

  • @kumaraguru.m6205
    @kumaraguru.m6205 9 місяців тому

    Awesome , Clear understanding ❤ Thanks for this video 🎉

  • @imededdinenezzar6344
    @imededdinenezzar6344 5 місяців тому

    man! your content is even better than the rust docs for sure!
    you got yourself a new subscriber :D

  • @mjk6035
    @mjk6035 2 роки тому

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

  • @WolfeyGamedev
    @WolfeyGamedev Рік тому

    Well done. This is exactly what I needed!

  • @drlytwatcher2646
    @drlytwatcher2646 3 роки тому +1

    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 :)

  • @cjmeyer429
    @cjmeyer429 3 роки тому

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

  • @pygeekrfoo820
    @pygeekrfoo820 Рік тому

    This is such impressive teaching. Good job.

  • @harrymiller7559
    @harrymiller7559 3 роки тому +2

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

  • @jhoughjr1
    @jhoughjr1 Рік тому +1

    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.

  • @RakavyYuval
    @RakavyYuval 3 роки тому +6

    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.

  • @jamiehagerty6732
    @jamiehagerty6732 3 роки тому

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

  • @Reydriel
    @Reydriel 7 місяців тому

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

  • @rootkill1581
    @rootkill1581 3 роки тому +1

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

  • @sagnikbhattacharya1202
    @sagnikbhattacharya1202 3 роки тому +3

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

  • @moaazk1936
    @moaazk1936 8 місяців тому

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

  • @gabonesmith4750
    @gabonesmith4750 Рік тому

    clear and concise explanation

  • @emmanuelelegbede2812
    @emmanuelelegbede2812 2 роки тому

    Amazing. this was really helpful and concise

  • @therealmattplayer
    @therealmattplayer 2 роки тому

    Perfectly explained, cheers.

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

  • @tr3ysmith
    @tr3ysmith 3 роки тому +1

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

  • @relaxsightme
    @relaxsightme 3 роки тому

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

  • @fallout__boy1130
    @fallout__boy1130 Рік тому

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

  • @andrefilipefonsecaborba4989
    @andrefilipefonsecaborba4989 2 роки тому

    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 ❤

  • @glener1000
    @glener1000 11 місяців тому

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

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

  • @TheBest-sd2qf
    @TheBest-sd2qf 2 роки тому

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

  • @Ryggis
    @Ryggis 3 роки тому

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

  • @orterves
    @orterves Місяць тому

    "Submodules must be declared in the parent module" omg that explains my confusion. I think I should put this as a sticky note on my monitor

  • @dedenapraia
    @dedenapraia 3 роки тому +1

    Finally ! Bogdan thank you for this. Rust Yedi !

    • @arimcbrown
      @arimcbrown 3 роки тому

      omg, I couldn't put my finger on it... You're right. He's the chosen one. ;)

  • @allisterquinn8049
    @allisterquinn8049 7 днів тому

    Can I ask what keyboard you have? It sounds so good!

  • @ryandsouza2962
    @ryandsouza2962 Рік тому

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

  • @marcocaspers3136
    @marcocaspers3136 Рік тому

    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.

    • @mindfulnessrock
      @mindfulnessrock 8 місяців тому

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

  • @raizul9978
    @raizul9978 3 роки тому

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

  • @liunox6023
    @liunox6023 2 роки тому

    thanks man, this is really great video.

  • @connorzittrauer3306
    @connorzittrauer3306 2 роки тому

    thank you, very well explained!

  • @winter_light
    @winter_light 3 роки тому

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

  • @schmoris
    @schmoris 10 місяців тому

    great explanation, thanks a lot!

  • @bencekeomley-horvath385
    @bencekeomley-horvath385 Рік тому +1

    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

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

  • @LuisMarinAguilera
    @LuisMarinAguilera 3 роки тому

    This video is pure gold!

  • @ClearerThanMud
    @ClearerThanMud 3 роки тому

    Nice job. In IntelliJ I find it convenient to just create modules in line and then tell IntelliJ to turn them into separate files.

  • @jonathanmoore5619
    @jonathanmoore5619 3 роки тому

    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?

  • @Only-zeus
    @Only-zeus 3 роки тому

    Happy new year bro cheers!! 🍻

  • @bjugdbjk
    @bjugdbjk 3 роки тому

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

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

  • @x1expert1x
    @x1expert1x Рік тому

    the "if let Status::Connected" line prevents me from compiling your code, "error[E0658]: `let...else` statements are unstable"

  • @yinkao_
    @yinkao_ Рік тому

    Thank you so much for this!

  • @nightfall2863
    @nightfall2863 10 місяців тому

    why is it like this tho is there a good reason to have it designed like this? why not be bound by folder path?

  • @fatemeetsluck
    @fatemeetsluck 2 роки тому

    This was much easier to understand than the official book.

    • @KoboldAdvocate
      @KoboldAdvocate Рік тому

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

  • @LordOfWizardurl
    @LordOfWizardurl 3 роки тому +1

    Please make a video on
    Emacs + Rust

  • @yapayzeka
    @yapayzeka 3 роки тому

    best rust channel out there

  • @post-modern-astrology
    @post-modern-astrology 3 роки тому

    Are there changes in module system with 2021 edition ?

  • @alfredomenezes8814
    @alfredomenezes8814 2 роки тому

    Amazing, thank you very much!

  • @PhosphorusMoscu-code
    @PhosphorusMoscu-code 3 роки тому

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

  • @sayantanchakrabarty1857
    @sayantanchakrabarty1857 Рік тому

    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 ?