Chapter 2: The Fundamental Structure of a Rust Program
This chapter outlines the core structure of a Rust program and introduces concepts that distinguish Rust from C and other systems programming languages. While many elements will feel familiar to C programmers, Rust brings new paradigms—such as ownership, strict typing, and powerful concurrency models—that improve memory safety and expressiveness.
We will compare Rust's syntax and conventions with those in C, providing short code examples to illustrate key ideas. Readers with prior Rust knowledge can skim or skip this chapter, but we recommend at least a quick review of the main concepts, especially if you're new to Rust's approach to memory and concurrency.
Some Rust features (e.g., the println!
macro) will appear in examples before being explained in depth. Here, we provide brief introductions to avoid confusion when they appear early on.