The only way to do this without breaking rust is by passing that constant as a parameter or by taking that constant outside main or another alternative is to make a "constants module" with all your constants,
What you are asking for is impossible because that private module can be accessed from anywhere in your crate where your 'constant' is not alive
What you are asking for is impossible because that private module can be accessed from anywhere in your crate where your 'constant' is not alive
This is not true, because, first, private module cannot be accessed from anywhere except main function, and, second, CONSTANT is static and alive for the whole duration of the program.
And this is just an example, in my case I need to access struct definitions defined in main, not a constant, so passing it by value wouldn't work.
In Rust a function does not define a namespace that can be used to control visibility and access to declarations, in the ways that a module namespace can. So you need to define another nested module to do that (like you have done), or move the shared declarations up one level to the containing module. That's the way the language is currently defined (for good or bad).
For me it was unexpected that defining a module and accessing things on its definition level (with super) doesn't work consistently.
Found it out when I was writing tests with definitions inside test functions.
I understand. It is natural to think of a function, and in particular a test function, as a namespace like any other namespace. And this difference is not yet very well documented, or at least I can't find any clear documentation about it.