A Simple Rust Project's Modules

I’m playing with Rust, and am trying to create a new project. The book goes into great detail about modules, but skip over the basic example of a small project with modules in different files.

For example:


mod story;

fn main() {
    println!("{}", story::tell());


pub fn tell() -> String {
    "foo bar".to_owned()

in a directory structure like this

$ tree -L 2
├── Cargo.lock
├── Cargo.toml
├── src
│   ├── main.rs
│   └── story.rs
└── target
    ├── debug
    └── rls

Rust is smart enough to know that the story.rs file contains the story module, and that mod story; in main.rs is talking about that file. It imports it into the context of the main file within the story namespace.