1# The `use` declaration 2 3The `use` declaration can be used to bind a full path to a new name, for easier 4access. It is often used like this: 5 6```rust,editable,ignore 7use crate::deeply::nested::{ 8 my_first_function, 9 my_second_function, 10 AndATraitType 11}; 12 13fn main() { 14 my_first_function(); 15} 16``` 17 18You can use the `as` keyword to bind imports to a different name: 19 20```rust,editable 21// Bind the `deeply::nested::function` path to `other_function`. 22use deeply::nested::function as other_function; 23 24fn function() { 25 println!("called `function()`"); 26} 27 28mod deeply { 29 pub mod nested { 30 pub fn function() { 31 println!("called `deeply::nested::function()`"); 32 } 33 } 34} 35 36fn main() { 37 // Easier access to `deeply::nested::function` 38 other_function(); 39 40 println!("Entering block"); 41 { 42 // This is equivalent to `use deeply::nested::function as function`. 43 // This `function()` will shadow the outer one. 44 use crate::deeply::nested::function; 45 46 // `use` bindings have a local scope. In this case, the 47 // shadowing of `function()` is only in this block. 48 function(); 49 50 println!("Leaving block"); 51 } 52 53 function(); 54} 55``` 56