Rust 中的 "item" 是什么?

What is an "item" in Rust?

Rust Book makes several references to the word "item", which confers the word a technical meaning in the context of the Rust programming language. For example, see Chapter 07-03:

The way privacy works in Rust is that all items (functions, methods, structs, enums, modules, and constants) are private by default. Items in a parent module can’t use the private items inside child modules, but items in child modules can use the items in their ancestor modules.

什么是项,是否有 Rust 中所有种类的完整列表?

Items - Rust Reference:

An item is a component of a crate. [...] There are several kinds of items:

  • Modules
  • extern crate declarations
  • use declarations
  • Function definitions
  • Type definitions
  • Struct definitions
  • Enumeration definitions
  • Union definitions
  • Constant items
  • Static items
  • Trait definitions
  • Implementations
  • extern blocks

An item is simply any declaration that could appear globally in a program or module, such as a fn, struct, or use.

参考:Rust 编程:快速、安全的系统开发(第 2 版)