The purpose of this repository is to improve understanding of Rust programming language concepts through coding, using the official Rust book as a foundation.
Please note that the repository does not contain any production-ready implementations and is not intended to be a complete project.
Therefore, the codebase structure does not follow any design patterns and is kept as simple as possible, with scope-based delimiters being used in most places.
The repository consists of several workspaces:
rust_book_runner
- serves as the workspace entry point and is responsible for enumerating and running a specific chapter.rust_book
- contains implementations for each chapter.- The other workspaces are chapter-specific implementations where the workspace is a more convenient way to represent a code sample compared to a module or a single rs-file.
Each chapter has a corresponding rs-file (rust_book/src/chapter_001.rs
) that contains a public function named pub fn run(subchapter: u32)
. This function serves as the entry point for the chapter and encapsulates sub-chapter calls.
Each subchapter corresponds to a function in the format fn chapter_m_n()
, where m
is the chapter index, and n
is the subchapter index.
$ rust_book_runner --help
Run specific chapter and subchapter.
To run a specific chapter and subchapter, you should specify the chapter ID in the format X.Y, where X is the chapter index and Y is the subchapter index.
For example, to run Chapter 3, Subchapter 2, you would specify 3.2:
$ rust_book_runner -c 3.2
If the chapter ID consists of a single number, that means all subchapters under the specified chapter number will be run.
If no chapter ID is specified, the most recent chapter will be run.
Usage: rust_book_runner [OPTIONS]
Options:
-c, --chapter-id <CHAPTER_ID>
Chapter ID. For example, `10.1`
[default: "ChapterID (0, 0)"]
-l, --list
List available chapters
-h, --help
Print help (see a summary with '-h')