Rust

Updated: 2021-11-23

Modules

  • Importing Modules with use
  • Re-exporting with pub use

Crate

Crate = library or package.

Each crate has an implicit root module that contains the code for that crate. You can then define a tree of sub-modules under that root module. Modules allow you to partition your code within the crate itself.

Methods vs Associated Functions

You can have two kinds of procedures: methods and associated functions.

  • methods: exists inside the struct implementation and receives the &self parameter, indicating that it needs to be called by an instance with a ..
  • associated functions: called without an instance, it can be compared with the Java static functions. They are normally are used as a constructor of instances.

Repos