I have a small project which built with no issues when it was all in one big .rs file. I wanted to make it easier to work with, so I broke it up into modules, and the projec
You need to put the extern crate rand;
line in you main.rs
and/or lib.rs
file. No need to put it in the other files.
Perhaps it is related to this bug.
To quote from the Crates and Modules chapter of the Rust book:
[...]
use
declarations are absolute paths, starting from your crate root.self
makes that path relative to your current place in the hierarchy instead.
The compiler is correct; there is no such thing as rand
, because you've put it inside a module, so the correct path to it would be GameState::ballstate::rand
, or self::rand
from within the GameState::ballstate
module.
You need to either move extern crate rand;
to the root module or use self::rand
within the GameState::ballstate
module.