Skip to content
Learn Netverks

Lesson

Step 29/36 81% through track

modules-crates

Modules and crates

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
advanced

This lesson

This lesson teaches Modules and crates: the syntax, APIs, and habits you need before advancing in Rust.

Teams ship Modules and crates on every Rust codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Modules and crates in contexts like: Infrastructure CLIs, proxies, game engines, blockchain nodes, and latency-sensitive backends.

Write Rust with fn main(), click Run on server—the dev runner compiles main.rs with rustc and runs the binary; fix borrow errors from stderr (requires Rust toolchain; LEARNING_RUNNER_ENABLED=true).

When functions, arrays, and basic OOP from intermediate lessons are familiar.

A crate is a compilation unit; modules organize code with mod, pub, and use. The playground is single-file, but real projects split into src/lib.rs and src/main.rs.

Module tree

mod front {
    pub fn hello() { println!("hi"); }
}

Important interview questions and answers

  1. Q: Crate vs package?
    A: Cargo package can contain multiple crates (lib + bin); crate is what rustc builds.

Self-check

  1. What keyword makes an item public?
  2. What does use do?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • mod vs pub mod?
  • crate vs package?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump