An absolute path identifies a Rust item from a crate root. External paths begin with a crate name, such as std::io::stdin; paths into the current crate begin with crate. section 5.2.1 section 5.4
Use absolute paths when accessing items across a module structure:
- Write crate::module::Item to reach an item from the current crate root. section 5.2.1
- Write an external crate name, such as std::io::stdin, to reach an item in another crate. section 5.2.1
- Expose modules or items with pub before accessing them from another module. section 5.2.1
- Shorten repeated absolute paths with use, as in use crate::treats::Treat;. section 5.2.1
The same snack API with absolute paths
Within a nested shop module, buy can return crate::treats::Treat and construct crate::treats::Treat::IceCream. The eat function can accept crate::treats::Treat and return crate::treats::ConsumedTreat, while regret can accept crate::treats::ConsumedTreat. These paths remain rooted at the crate rather than at the current module.

