Defining Modules to Control Scope and Privacy - The Rust Programming Language
In this section, we’ll talk about modules and other parts of the module system, namely paths, which allow you to name items; the use keyword that brings a path into scope; and the pub keyword to make items public. We’ll also discuss the as keyword, external packages, and the glob operator. Before we get to the details of modules and paths, here we provide a quick reference on how modules, paths, the use keyword, and the pub keyword work in the compiler, and how most developers organize their code. We’ll be going through examples of each of these rules throughout this chapter, but this is a great place to refer to as a reminder of how modules work. Here, we create a binary crate named backyard that illustrates these rules. The crate’s directory, also named backyard, contains these files and directories: The crate root file in this case is src/main.rs, and it contains: The pub mod garden; line tells the compiler to include the code it finds in src/garden.rs, which is: Here, pub mod veget
Control Scope and Privacy with Modules - The Rust Programming Language Keyboard shortcuts Press ← or → to navigate between chapters Press S or / to search in the book Press ? to show this help Press Esc to hide this help Auto Light Rust Coal Navy Ayu The Rust Programming Language Control Scope and Privacy with Modules In this section, we’ll talk about modules and other parts of the module system, namely paths , which allow you to name items; the use keyword that brings a path into scope; and the pub keyword to make items public. We’ll also discuss the as keyword, external packages, and the glo
Explore this link on the map →related reading
- Paths for Referring to an Item in the Module Tree - The Rust Programming Languagedoc.rust-lang.org
- Bringing Paths Into Scope with the use Keyword - The Rust Programming Languagedoc.rust-lang.org
- A half-hour to learn Rustfasterthanli.me
- Rust Language Cheat Sheetcheats.rs
- Methods - The Rust Programming Languagedoc.rust-lang.org
- What is Ownership? - The Rust Programming Languagedoc.rust-lang.org
- Programming a Guessing Game - The Rust Programming Languagedoc.rust-lang.org
- Modules :: Eloquent JavaScripteloquentjavascript.net
- Modular Errors in Rust - Sabrina Jewsonsabrinajewson.org
- The Linux Kernel Module Programming Guidesysprog21.github.io
- Macros - The Rust Programming Languageweb.mit.edu
- Shared modules / The $lib alias • Svelte Tutoriallearn.svelte.dev