A Simple Rust Project's Modules

As I’ve been playing with Rust I keep running into issues with making code defined in one part of the crate available in other parts. To help sort things out I put together a project that demonstrates a bunch of ways to import code from different parts of the crate. It’s called import-of-call.

The single biggest hangup that seems to get beginners is that you can have two different crates in the same directory with a single Cargo.toml. The first is the one you would expect, based on main.rs, this is called the binary crate. The other is based on lib.rs and is the library crate. You can’t import code into both of them with mod. If you have both you should probably bring it into the library crate, and include that wholesale into the binary crate. I’m not 100% this is idiomatic, but it’s worked for me so far.