07 Modules, Pub and Use | Rust Tutorials

Publié le: 20 juin 2020
sur la chaîne: Jeff No Zhao
21,588
771

In this video I cover the Rust module system and how it interacts with public/private scope as well as importing our modules using the use keyword. Modules in Rust function very similarly to packages in Java or Python and modules in Javascript. They allows us to breakdown our code into more readable and more reusable pieces.

Find me elsewhere:
Instagram:   / jeff.no.zhao  
Github: https://github.com/kamiyaa

There are many ways to structure modules in Rust.
The main 3 ways are:

1. Using them inside a single file
2. Separating them into multiple files
3. Separating them into multiple folders

If you liked the video, please like, comment and subscribe!

The first way, all we need to do is use the mod keyword.
The second way, we no longer need the mod keyword, but we must name our file the same as our module.
The last way, our file must be named mod.rs and our directory must be named the same as our module.
Modules can be private (by default) or public using the pub keyword.

By using the use keyword, we bring modules into scope for our program to use.

If you have topics you want me to cover in future videos, leave a comment down below.

Check out the entire playlist here:    • Rust Tutorials  


Sur cette page du site, vous pouvez voir la vidéo en ligne 07 Modules, Pub and Use | Rust Tutorials durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Jeff No Zhao 20 juin 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 21,588 fois et il a aimé 771 téléspectateurs. Bon visionnage!