← All notes

Rust packages, crates, and modules with privacy

Answer: A crate is the smallest amount of code the Rust compiler considers at a time. Every package needs at least one crate (library, binary, or both).

Modules and privacy

Modules control item privacy; code inside a module stays private by default. Items in a parent module can't use the private items inside child modules.

Rust by Example calls a crate a compilation unit.

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Rust book + Rust by Example Crates page (MIT OR Apache-2.0). Notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT).

Cite this

Permanent ID: iil:note:z61ytaw1

iinventedlight. 2026. "Rust packages, crates, and modules with privacy." iinventedlight Library, iil:note:z61ytaw1, version of 2026-11-09. https://iinventedlight.com/library/notes/rust-packages-crates-modules/. License: CC-BY-4.0.

@misc{iil_note_z61ytaw1,
  author = {{iinventedlight}},
  title = {{Rust packages, crates, and modules with privacy}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-09},
  url = {https://iinventedlight.com/library/notes/rust-packages-crates-modules/},
  note = {Permanent ID iil:note:z61ytaw1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/rust-packages-crates-modules.md.