Shouldn't struct fields be private in all cases?


This seems to work fine:
Shouldn’t printing the contents of blackbox fail? The only difference between this and the example here is that I removed the mod declaration at the top. Where am I going wrong?


Privacy doesn’t apply within a module; private things are only private to code outside the defining module. In this case, everything is in the same module, so nothing is really private.

To quote the third sentence from the page you linked:

This visibility only matters when a struct is accessed from outside the module where it is defined…


Makes sense, thanks!