flâneur — a map of the web's best reading

Defining Modules to Control Scope and Privacy - The Rust Programming Language

doc.rust-lang.org · 1,255 words · saved by 1 readers

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