How to access const values from bin to lib

Hey guys so if I have a bin and it connects to a lib, and in the file I have a const

pub const DEBUG: bool       = true;

Inside one of the lib project files, how would I exactly access this variable?

Your binary can access code from your library, but your library cannot access code from your binary.

Any code shared across both crates should be in the library.


does the const DEBUG need to be inside the binary?

you can define it as a static inside your library and then set it inside the binary


static DEBUG: Lazy<Mutex<bool>> = Lazy::new(Mutex::default);

fn set_debug(b: bool) { .. }


fn main() {

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.