What is the difference between `use abc;` and `mod abc;`?


#1

Like the title says: What is the difference between use abc; and mod abc;?

For example I need to do use std::env; if I want to access stuff in the std::env namespace. But I can’t do the same thing for a module contained in the my own project (crate?). Instead I have to do mod mymod; to make the contents of mymod accessible from current scope.

Why do have two ways of doing the same thing?


#2

mod abc; declares a module.use abc;brings a nameabc` into scope.

This is because of the prelude; Rust has already done an extern crate std to bring std into existence.


#3

Okay, this explains things. Thanks!