Loading tutorials
Result), understand ownership at an introductory level, and run cargo build and cargo run. Nothing else is needed.2 min readResult), understand introductory ownership and borrowing, and can run cargo build and cargo run. Packages and crates were covered in the previous chapter. Here we look at how code inside one crate is grouped.2 min readuse shortens those names.2 min readmod blocks, know what pub does, and can run cargo build. Here you will move modules out of one file and into a directory layout that Cargo and the compiler follow.2 min readuse declarations, and mark items pub. It covers how pub use lets you separate where code lives from the path users see.2 min readpub, and run cargo build and cargo run. It builds on the idea that a package is what Cargo manages and a crate is what the compiler builds.2 min readcargo build, and can read basic TOML. It covers how Cargo decides which versions of other crates your package uses, and what to check when that goes wrong.2 min readCargo.toml, know the difference between a package and a crate, and have added a dependency before. A feature is a named switch that lets one crate be built in different configurations.2 min readcargo new, know the difference between a library crate and a binary crate, and can declare a dependency in Cargo.toml.2 min readCargo.toml, know how [dependencies] entries work, and have run cargo test at least once. It covers the [dev-dependencies] table: what it is for, where it applies, and the mistakes that come with it.2 min readuse work, and how to run cargo build. Rust lets you put unit tests in the same file as the code they check. This chapter shows how that works and why it gives tests access to private items.3 min read#[test] function inside a #[cfg(test)] module and run cargo test. It covers how a test passes or fails, and three ways to express what you expect.2 min read#[cfg(test)], how pub controls visibility, and the difference between a library crate and a binary crate. Integration tests check your crate the way a user would, through its public API only.2 min read#[cfg(test)], know the difference between a library crate and a binary crate, and can use pub use to re-export items. Documentation tests (doc tests) turn the examples in your doc comments into real tests.2 min read#[test] functions, know the difference between unit, integration, and doc tests, and can run cargo build from the command line. Here you learn how cargo test chooses which tests to run and how to change its behavior.2 min read