Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


x-i18n: generated_at: “2026-03-01T13:14:33Z” model: gemini-3-flash-preview provider: google-gemini-cli source_hash: 577cfc9c38aef8a921625806872f74d15d26e6457e3f7249665ea7afef29e014 source_path: ch03-00-common-programming-concepts.md workflow: 16

通用编程概念 (Common Programming Concepts)

Common Programming Concepts

本章介绍了几乎在所有编程语言中都会出现的概念,以及它们在 Rust 中是如何工作的。许多编程语言的核心都有很多共同点。本章介绍的概念都不是 Rust 特有的,但我们将在 Rust 的背景下讨论它们,并解释使用它们的约定。

This chapter covers concepts that appear in almost every programming language and how they work in Rust. Many programming languages have much in common at their core. None of the concepts presented in this chapter are unique to Rust, but we’ll discuss them in the context of Rust and explain the conventions around using them.

具体来说,你将学习变量、基本类型、函数、注释和控制流。这些基础将出现在每一个 Rust 程序中,及早学习它们将为你提供一个坚实的核心。

Specifically, you’ll learn about variables, basic types, functions, comments, and control flow. These foundations will be in every Rust program, and learning them early will give you a strong core to start from.

关键字 (Keywords)

Keywords

与其他语言类似,Rust 语言有一组仅供语言本身使用的 关键字 (keywords)。请记住,你不能使用这些单词作为变量或函数的名称。大多数关键字具有特殊的含义,你将使用它们在 Rust 程序中完成各种任务;少数关键字目前没有关联的功能,但已为将来可能添加到 Rust 的功能而保留。你可以在 附录 A 中找到关键字列表。

The Rust language has a set of keywords that are reserved for use by the language only, much as in other languages. Keep in mind that you cannot use these words as names of variables or functions. Most of the keywords have special meanings, and you’ll be using them to do various tasks in your Rust programs; a few have no current functionality associated with them but have been reserved for functionality that might be added to Rust in the future. You can find the list of the keywords in Appendix A.