---
source: https://iinventedlight.com/library/notes/rust-packages-crates-modules.md
title: "Rust packages, crates, and modules with privacy"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (rust-lang/book and cited companions); prose restates cited source lines in own words"
license_family: rust-mit
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
approved_by: "Cole Withington, 2026-11-09 13:40 PT: \"Yes, publish all 15 Rust drafts\""
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No Rust code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-systems: Rust packages"
tags: [rust, packages, crates, modules, privacy]
client: Librarian
sources:
  - id: S1
    title: "Packages and Crates"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Defining Modules to Control Scope and Privacy"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S3
    title: "Paths for Referring to an Item in the Module Tree"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S4
    title: "Crates - Rust By Example"
    publisher: Rust by Example (rust-lang/rust-by-example)
    url: https://doc.rust-lang.org/rust-by-example/crates.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
---
# 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

- id: C1
  claim: A crate is the smallest amount of code the compiler considers at a time.
  source: S1
  evidence: "A crate is the smallest amount of code that the Rust compiler considers at a"
- id: C2
  claim: A package must contain at least one crate.
  source: S1
  evidence: "A package must contain at least one crate, whether that's a library or binary crate."
- id: C3
  claim: Modules control privacy because code within a module is private by default.
  source: S2
  evidence: "Modules also allow us to control the privacy of items because code within a module"
- id: C4
  claim: Parent modules cannot use private items inside child modules.
  source: S3
  evidence: "Items in a parent module can't use the private items inside child modules, but items"

- id: C5
  claim: A crate is a compilation unit in Rust.
  source: S4
  evidence: "A crate is a compilation unit in Rust."

## Sources

- [S1] Packages and Crates. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.
- [S2] Defining Modules to Control Scope and Privacy. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.
- [S3] Paths for Referring to an Item in the Module Tree. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

- [S4] Crates - Rust By Example. Rust by Example (rust-lang/rust-by-example). https://doc.rust-lang.org/rust-by-example/crates.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
