-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodules3.rs
More file actions
47 lines (35 loc) · 930 Bytes
/
modules3.rs
File metadata and controls
47 lines (35 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::deeply::nested::{
my_first_function,
my_second_function,
AndATraitType
};
fn main() {
my_first_function();
}
---------------------------------
use deeply::nested::function as other_function;
fn function() {
println!("called `function()`");
}
mod deeply {
pub mod nested {
pub fn function() {
println!("called `deeply::nested::function()`");
}
}
}
fn main() {
// Easier access to `deeply::nested::function`
other_function();
println!("Entering block");
{
// This is equivalent to `use deeply::nested::function as function`.
// This `function()` will shadow the outer one.
use crate::deeply::nested::function;
function();
// `use` bindings have a local scope. In this case, the
// shadowing of `function()` is only in this block.
println!("Leaving block");
}
function();
}