Rust Functions and Modules 🦀

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025
  • In this video, we take a look at defining Rust functions with input parameters and output values. We also will explore how to organize Rust code into modules and child modules. Each member of a Rust module has private or public visibility; by default it's private. In order for a function to be exposed from a Rust module, you will need to specify public visibility. Rust modules can be defined in separate source code files and referenced from your main (entrypoint) module. Although the Rust compiler (rustc) can only accept a single source code file as input, any referenced module files will be included during the compilation step.
    🤯 Rust Programming Playlist 🦀 • Rust Programming Tutor...
    📖 Rust Modules: doc.rust-lang....
    📖 Rust Functions: doc.rust-lang....
    Visual Studio Code ➡️ code.visualstu...
    Rust Website ➡️ rust-lang.org
    Rustup Installer ➡️ rustup.rs
    Rust Docs ➡️ doc.rust-lang....
    Please follow me on these other social channels!
    ➡️ trevorsullivan...
    ➡️ github.com/pcg...
    ➡️ / pcgeek86
    ➡️ / trevorsullivan
    ➡️ / trevorsoftware
    ➡️ tiktok.com/pcg...
    All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names,trademarks and brands does not imply endorsement.
    #opensource #software #linux #devops #programming #rusty #rustdev #dev #coding #codinglife #code #coder #ubuntu #ubuntulinux #appdev #rustlang #rust #developer

ความคิดเห็น • 50

  • @TrevorSullivan
    @TrevorSullivan  ปีที่แล้ว +4

    🦀🦀🦀 Rust Programming Tutorial Playlist 🦀🦀🦀
    th-cam.com/play/PLDbRgZ0OOEpUkWDGqp91ODn0dk7LPBAUL.html
    🖥🖥🖥 LXD Virtualization on Linux Playlist 🖥🖥🖥
    th-cam.com/play/PLDbRgZ0OOEpX_uqK_hAq98ltdc4DP-D34.html

  • @osmanovitch7710
    @osmanovitch7710 11 หลายเดือนก่อน +8

    finally , someone explains RUST verry well

  • @Exidiful
    @Exidiful ปีที่แล้ว +9

    I just started following your series and Im telling you man.. finally, Im understanding and learning rust.
    Love how you always explain why and ask questions that make us think.
    Because of you I will finally be able to tell people "I use rust btw"
    Really appreciate this ❤

  • @STgA97
    @STgA97 หลายเดือนก่อน

    This is the absolute best Rust tutorial series in existence! Tysm

    • @TrevorSullivan
      @TrevorSullivan  หลายเดือนก่อน

      Thank you so much! 🦀 Happy new year!

  • @chiruchintha
    @chiruchintha 6 หลายเดือนก่อน +2

    finally someone explaining rust very well

  • @karthikpuvvula
    @karthikpuvvula 10 หลายเดือนก่อน +1

    This is the best Rust tutorial on YT. I tried a lot of famous channels but your explanation style and depth is simply awesome. Thank you!

    • @TrevorSullivan
      @TrevorSullivan  10 หลายเดือนก่อน

      Thank you for your kind comment, Karthik! I am so happy to hear that you're learning from my channel. Enjoy using Rust to build applications! 🦀

  • @vamshikrishna4008
    @vamshikrishna4008 10 วันที่ผ่านมา

    Thank you for making Rust so easy to understand

  • @bliss_anand
    @bliss_anand 6 หลายเดือนก่อน

    Hi Trevor, Your playlist is damn impressive. No BS, only useful stuff. Subbed!

  • @ibrahimyıldız-i3q
    @ibrahimyıldız-i3q 7 หลายเดือนก่อน

    absolutely amazing, as a beginner to rust. This helps quite a lot, youre going over the small details and everything.
    A very nice idea for your channel growth could be rust shorts, where you summarize these videos. keep up the good work 👍👍👍

    • @TrevorSullivan
      @TrevorSullivan  7 หลายเดือนก่อน

      Thank you very much! I'm glad you're benefiting from these videos. God bless you. ❤️

    • @TrevorSullivan
      @TrevorSullivan  7 หลายเดือนก่อน

      I've actually experimented with a few Rust shorts. I'm not a big fan of creating Shorts though! I enjoy making long form videos that teach new concepts. I appreciate the idea though. 😊

  • @Amir-bd4uk
    @Amir-bd4uk 10 หลายเดือนก่อน

    Thank you for making this series. I'm watching your videos to get started with Rust and i really appreciate how clearly you explain everything.

  • @iDeibits
    @iDeibits 6 หลายเดือนก่อน

    Excellent, very clear explanations. Thanks for helping Rustaceans

  • @ashisharya65
    @ashisharya65 ปีที่แล้ว +1

    Another great video Trevor.
    I have been watching your videos since the day I started learning PowerShell and now learning Rust using this amazing playlist.
    Thanks a lot for this. 😊

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว +1

      I'm glad you're enjoying Rust as well, Ashish!! It's more complex but very good knowledge to have! Just think what you'll be able to do with it a year from now! 🦀🦀

    • @ashisharya65
      @ashisharya65 ปีที่แล้ว

      @@TrevorSullivan : I have a question, is Rust a good programming language to be used in cloud (Azure/AWS) development at this moment?

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว +1

      @@ashisharya65 good question!! I'm not sure what the maturity of the AWS or Azure SDKs for Rust looks like. I'll eventually be taking a look at them! 🦀

  • @jasonbraithwaite9204
    @jasonbraithwaite9204 9 หลายเดือนก่อน

    Superb, well explained and easy to understand. Thank you Trevor :)

  • @engsmyle
    @engsmyle 2 หลายเดือนก่อน

    Thank you so much, for this video. I need to learn that to start my journey as a Solana developer

  • @amirerfanian4418
    @amirerfanian4418 ปีที่แล้ว

    Hello Trevor , thank you SO much for your time , your explanation is exceptional man ! where were you so far ?! you are amazing teacher ! thank you again for your time and efforts

  • @kasugaryuichi9767
    @kasugaryuichi9767 ปีที่แล้ว

    Thank you so much for making these!

  • @ImranKhan-br5dv
    @ImranKhan-br5dv 10 หลายเดือนก่อน

    your channels teach us just as the Hitesh sir , an indian teacher .

  • @Ehmiiz
    @Ehmiiz ปีที่แล้ว

    Love this series!

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว

      Thank you so much! I am glad you are benefitting from it! Rust on 🦀

  • @terraflops
    @terraflops ปีที่แล้ว

    i am new to Rust and having a hard time with it, i found your video on the side panel of TH-cam (my issue was with importing modules), hoping to learn from you and have more positive experience with Rust. (new subscriber)

  • @AryungChen
    @AryungChen ปีที่แล้ว

    Easy to understand !! awesome

  • @symshark
    @symshark ปีที่แล้ว

    Hello Trevor, I am working through the book The Rust Programming Language, 2nd Edition but your videos do provide more clarity and are really helping me out through my rust programming journey. I was just curious if there is a reason for using the return statement instead of just using an expression to return the value of the function? is it based on preference?Thank you for all your help and I hope you keep creating more rust programming videos.

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว +1

      Hello @symshark, and thanks for your supportive comment! To answer your question, yes, I use the "return" keyword because it's more explicit than simply specifying an expression without the semi-colon. Of course it's valid to use either approach, so feel free to use the one that suits you best! For people who are new to Rust programming, I think using the return keyword is easier to visualize, when scanning some code samples. 🙂 I will be publishing more Rust programming videos! 🦀Rust on!!!

    • @symshark
      @symshark ปีที่แล้ว +1

      @@TrevorSullivan That makes sense, thank you!

  • @weeb3277
    @weeb3277 6 หลายเดือนก่อน +2

    11:23 but do you need the keyword pub there? works without it.

    • @TrevorSullivan
      @TrevorSullivan  6 หลายเดือนก่อน +1

      Probably not - good point!

  • @xXYourShadowDaniXx
    @xXYourShadowDaniXx 5 หลายเดือนก่อน

    I could have used this a while ago when I code split into modules for my command line todo project.

  • @anjonsarker2374
    @anjonsarker2374 ปีที่แล้ว

    Outstanding

  • @subhamprasad1373
    @subhamprasad1373 ปีที่แล้ว

    Thank you 🎉

  • @ThisGuyDakota
    @ThisGuyDakota ปีที่แล้ว +1

    I'm self-taught in powershell and python and a little lacking in my understanding of the heap/stack (and why to do things with them in mind). So kind of wondering why we've been using &str (string pointers) all this time instead of a regular String?
    Is it just to utilize the performance that Rust is known for, since the &str is just borrowing a value, and (I'm assuming) String creates a dedicated spot in memory?

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว

      Great question, and something that I've been seeking to understand better (beyond just Rust) for YEARS.
      In the Rust by Example book, they talk a little bit about this: doc.rust-lang.org/rust-by-example/std/box.html
      Quote: "All values in Rust are stack allocated by default. Values can be boxed (allocated on the heap) by creating a Box. "
      If we look at the article, in the same book, covering Rust Strings (capital S), we can see that: "String is heap allocated, growable and not null terminated."
      The difference with static strings (&str) is that they point to a stack-allocated value with a KNOWN length, whereas the String type is resizable on the heap.
      Link: doc.rust-lang.org/rust-by-example/std/str.html
      Hope that helps? 🙂

    • @ThisGuyDakota
      @ThisGuyDakota ปีที่แล้ว

      @TrevorSullivan Still a bit fuzzy, but that's a great deal of info that'll probably point me in the right direction so thanks, much appreciated!

  • @FentForEnt
    @FentForEnt 8 หลายเดือนก่อน

    nice video!

  • @drac8854
    @drac8854 ปีที่แล้ว

    Hi
    I have a suggestion
    But before that i wanted to let you know that i have not yet watched/followed your rust Playlist i have it saved but i am procrastinating 😅 (Sorry)
    In my opinion a great way to teach rust would be to create some software/application.
    And showcasing it in the start.
    For me it sets a goal in my mind as yes i have to create this thats why i have to watch next video to understand.
    Surly it doesn't have to be a big software for start up we could start with just todo app or even a basic app that convert number to words.
    As long as i am motivated to build that thing i'll learn rust.
    (I hope i am making sense)
    I found your video because i was trying to convert one typescript code to rust and i was confused...
    But that project went to dump because i dont know some cycle error.....

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว

      Yes, I agree that example driven training can be helpful. However, people often need to know how to do a very specific thing in Rust. That's why the foundational learning is important in addition to building sample applications! One isn't necessarily better than the other, they're just different learning styles for people at different stages of their learning progression. Good feedback to keep in mind though! Thank you!

  • @adityakiran2956
    @adityakiran2956 8 หลายเดือนก่อน

    Awesome video!!! really learnt a lot, gave up came to YT after failing to understand docs
    Can anyone tell me what theme and extension is being used for Rust?

    • @TrevorSullivan
      @TrevorSullivan  8 หลายเดือนก่อน

      Thank you for your kind words!
      The theme is "outrun" by "samrapdev" and the extension is Rust Analyzer.

  • @ERAYKAAN850
    @ERAYKAAN850 ปีที่แล้ว +1

    Can you show modules more in depth? I mean like creating folders, files in it and more. You just showed how to create files and use them. But nice video!

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว

      Thanks for the idea! One of the upcoming topics will be crates, which will allow you to organize your code into libraries. I'll see if I can go into more depth on modules as well.

  • @subhamprasad1373
    @subhamprasad1373 ปีที่แล้ว

    Why was the binary 4 mb in size ??

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว +2

      Probably because I compiled it in debug mode, not release mode.

    • @subhamprasad1373
      @subhamprasad1373 ปีที่แล้ว +1

      @@TrevorSullivan thanks for your quick reply 👏, really you have done amazing job 💯 in your videos

    • @TrevorSullivan
      @TrevorSullivan  ปีที่แล้ว +1

      @@subhamprasad1373 thanks so much for your kind feedback! 🙂