Referring names to different modules

Normally, when using Modules in Rust we need to do something like this:


pub mod a {
    pub mod series {
        pub mod of {
            pub fn nested_module() {

            }
        }
    }
}

fn main() {
    a::series::of::nested_module();
}

We can fix this by using a use keyword.

use a::series::of::nested_module;
fn main() {
    nested_module();
}

We can also use the use keyword with enums:

enum TrafficLight{
    Red, Yellow, Green
}

use TrafficLight::{Red,Yellow}
fn main() {
    let red = Red;
    let yellow = Yellow;
    let green = TrafficLight::Green;
}