Rust anatomy: Difference between revisions

From wikinotes
Line 27: Line 27:
== Packages ==
== Packages ==
<blockquote>
<blockquote>
A package is a collection of crates.


* it may have multiple executable crates
* it may only have one library crate
</blockquote><!-- Packages -->
</blockquote><!-- Packages -->



Revision as of 22:40, 7 February 2023

A rust project comprises of

packages build/test/share a collection of crates
crates tree of modules that build a single library, or executable
modules organize scope/privacy of paths
paths files ?
package:
    - crate:
    - crate:
        - module:
        - module:
            - path
            - path

Components

Packages

A package is a collection of crates.

  • it may have multiple executable crates
  • it may only have one library crate

Crates

A crate can be either

  • a library (has src/lib.rs entrypoint)
  • an executable (has src/main.rs entrypoint)