Clarify what the two problems modules solve are

Fixes #240.
This commit is contained in:
Carol (Nichols || Goulding)
2016-08-30 12:34:02 -04:00
parent 29c74cc4df
commit a09f376ca4
+8 -5
View File
@@ -5,11 +5,14 @@ the `main` function. As your code grows, you eventually move functionality out
into functions, both for re-use and for nicer organization. By splitting your
code up into smaller chunks, each chunk is easier to understand on its own. So
what happens when you start having too many functions? Rust has a module system
that tackles both of these problems. In the same way that you extract some lines
of code into a function, you can extract some functions (and other things too)
into different modules. A *module* is a namespace that contains definitions of
functions or types, and those definitions can be visible outside their module
or not. Here's an overview of how the bits fit together:
that tackles both the problem of wanting to be able to re-use code and the
problem of keeping your code organized.
In the same way that you extract lines of code into a function, you can extract
functions (and other code like structs and enums too) into different modules. A
*module* is a namespace that contains definitions of functions or types, and
those definitions can be visible outside their module or not. Here's an
overview of how the bits fit together:
* `mod` declares a new module.
* Everything starts off as private, but the `pub` keyword makes it public.