Rust access control

From wikinotes

By default in rust, everything is private (current module access only).


visibility and privacy


  • Objects are private by default.
  • A private object instance cannot be returned to a different module.
  • A public struct with private fields cannot be instantiated outside of it's module.


  • Modules are private by default, but can be published by their parent module
  • Parent modules are not visible to their children by default, but can be accessed with super or with absolute paths from crate::
  • Modules are implied by the filename, you can however create a submodule within a file using mod ${your_module}