Cross-module Variables
⚓ Rust 📅 2026-06-19 👤 surdeus 👁️ 2I have a Rust project split into 3 files:
main.rsconfig.rsgenerate.rs
Inside config.rs are variables which are given values by TOML structs. I am required to inject those variables into generate.rs as part of a function within that module. I have imported the config module, yet the compiler throws errors regarding the variables being out-of-scope. The variables are within a function in config.rs as Rust seems to disallow using let in global scope.
How can I allow Rust to inject immutable let variables from another module into a module's function?
8 posts - 3 participants
🏷️ Rust_feed