Update multiple file use statement example
Update the example to make the usage of `pub mod foo;` much more apparent, as well as using an example where setting the visibility of the module is actually necessary.
This commit is contained in:
parent
bd3fb81e5e
commit
949143e17a
@ -2992,21 +2992,23 @@ And here an example with multiple files:
|
||||
~~~{.ignore}
|
||||
// `a.rs` - crate root
|
||||
use b::foo;
|
||||
use b::c::bar;
|
||||
mod b;
|
||||
fn main() { foo(); }
|
||||
fn main() {
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
~~~
|
||||
|
||||
~~~{.ignore}
|
||||
// `b.rs`
|
||||
use b::c::bar;
|
||||
// `b/mod.rs`
|
||||
pub mod c;
|
||||
pub fn foo() { bar(); }
|
||||
pub fn foo() { println!("Foo!"; }
|
||||
~~~
|
||||
|
||||
~~~
|
||||
// `c.rs`
|
||||
pub fn bar() { println!("Baz!"); }
|
||||
# fn main() {}
|
||||
~~~{.ignore}
|
||||
// `b/c.rs`
|
||||
pub fn bar() { println!("Bar!"); }
|
||||
~~~
|
||||
|
||||
There also exist two short forms for importing multiple names at once:
|
||||
|
Loading…
x
Reference in New Issue
Block a user