Rust access control

From wikinotes
Revision as of 15:17, 8 February 2023 by Will (talk | contribs) (Created page with "By default in rust, everything is private (current module access only). = Documentation = {| | visibility and privacy || https://doc.rust-lang.org/reference/visibility-and-privacy.html |} = Objects = <blockquote> * 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. </blockquote><!-- objects --> = Modules = <blockquote> * Modules are...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Documentation

visibility and privacy https://doc.rust-lang.org/reference/visibility-and-privacy.html

Objects

  • 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

  • Modules are private by default
  • Modules are implied by the filename, you can however create a submodule within a file using mod ${your_module}