2022-09-07 05:11:09 +00:00
|
|
|
// ./src/mod/use.md
|
|
|
|
|
2022-09-07 05:36:14 +00:00
|
|
|
/*
|
2022-09-07 05:11:09 +00:00
|
|
|
use crate::deeply::nested::{
|
|
|
|
my_first_function,
|
|
|
|
my_second_function,
|
|
|
|
AndATraitType
|
|
|
|
};
|
|
|
|
|
|
|
|
fn part0() {
|
|
|
|
my_first_function();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bind the `deeply::nested::function` path to `other_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 part1() {
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// `use` bindings have a local scope. In this case, the
|
|
|
|
// shadowing of `function()` is only in this block.
|
|
|
|
function();
|
|
|
|
|
|
|
|
println!("Leaving block");
|
|
|
|
}
|
|
|
|
|
|
|
|
function();
|
2022-09-07 05:36:14 +00:00
|
|
|
}*/
|
2022-09-07 05:11:09 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2022-09-07 05:36:14 +00:00
|
|
|
// part0();
|
|
|
|
// part1();
|
2022-09-07 05:11:09 +00:00
|
|
|
}
|
|
|
|
|