5
votes

The 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.

What is an item and is there a comprehensive list of all the kinds that there are in Rust?

2

2 Answers

4
votes

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
1
votes

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

Reference: Programming Rust: Fast, Safe Systems Development (2nd Edition)