Cross-module Variables

⚓ Rust    📅 2026-06-19    👤 surdeus    👁️ 2      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Cross-module Variables

I have a Rust project split into 3 files:

  • main.rs
  • config.rs
  • generate.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

Read full topic

🏷️ Rust_feed