We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Modules, Visibility, Testing and Docs
RustOrganize code into modules, choose public interfaces, and write tests and documentation that help callers use your code correctly.
This track uses Rust. You can make it your practice mode to browse related content across the site.
Your learning sequence
- 1 Not solved yet. Build a module tree and inspect its paths Practice · Easy
- 2 Not solved yet. Paths: absolute, relative, crate::, self::, super:: Practice · Easy
- 3 Not solved yet. Expose a small module API Practice · Easy
- 4 Not solved yet. Restricted visibility: pub(crate), pub(super), pub(in path) Practice · Medium
- 5 Not solved yet. use declarations: nested groups, as, self, and _ Practice · Medium
- 6 Not solved yet. Resolve names in a simplified import model Practice · Medium
- 7 Not solved yet. Three namespaces: types, values, and macros Practice · Medium
- 8 Not solved yet. Model public item paths and re-exports Practice · Hard
- 9 Not solved yet. The five preludes Practice · Medium
- 10 Not solved yet. macro_rules! scoping is not item scoping Practice · Hard
- 11 Not solved yet. Module file layout: foo.rs, foo/mod.rs, and #[path] Practice · Medium
- 12 Not solved yet. Conditional compilation with cfg and cfg_select! Practice · Medium
- 13 Crate vs package vs workspace vs module Read
-
14
Cargo.tomlessentials Read - 15 Not solved yet. Version requirements: caret, tilde, wildcard, pre-releases Practice · Medium
- 16 Not solved yet. Cargo features and the additivity rule Practice · Hard
- 17 Not solved yet. SemVer for Rust APIs: what actually breaks Practice · Hard
- 18 Workspaces, publishing, MSRV and docs.rs Read
-
19
#[test], the assert macros, and what a test actually is Read - 20 Not solved yet. Build a test runner that catches panics Practice · Hard
-
21
Unit tests,
#[cfg(test)], integration tests and the lib+bin split Read - 22 Not solved yet. Test selection: filters, #[ignore], and the libtest CLI Practice · Medium
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
With Cargo's default test discovery, why can tests/api.rs call double but not private_helper?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
// src/lib.rs
fn private_helper(x: i32) -> i32 {
x * 2
}
pub fn double(x: i32) -> i32 {
private_helper(x)
}
// tests/api.rs (a separate file; the library crate is named my_crate)
#[test]
fn doubles_a_value() {
assert_eq!(my_crate::double(21), 42);
}