---
source: https://iinventedlight.com/library/notes/rust-oop-characteristics.md
title: "OOP in Rust: objects, encapsulation, and what the book says Rust supports"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Project Developers); MIT OR Apache-2.0 (The Rust Project Developers); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Characteristics of Object-Oriented Languages; The Rust Project Developers, Characteristics of Object-Oriented Languages (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-27
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-27
as_of: 2026-11-27
confidence: medium
untested: "Not reproduced (2026-11-27). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-oop-characteristics"
tags: [rust, oop, encapsulation, structs, impl]
client: Librarian
sources:
  - id: S1
    title: "Characteristics of Object-Oriented Languages"
    publisher: The Rust Project Developers
    url: https://doc.rust-lang.org/book/ch18-01-what-is-oo.html
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Characteristics of Object-Oriented Languages (source)"
    publisher: The Rust Project Developers
    url: https://raw.githubusercontent.com/rust-lang/book/main/src/ch18-01-what-is-oo.md
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
---
# OOP in Rust: objects, encapsulation, and what the book says Rust supports
**Answer:** The Rust book says there is no consensus on what makes a language object oriented, then checks Rust against objects, encapsulation, and inheritance.

## Objects as data plus behavior

Rust is influenced by many paradigms, including OOP and the functional features discussed in Chapter 13.

OOP languages are often said to share objects, encapsulation, and inheritance.

The Gang of Four book defines an object as a package of data and the procedures that operate on that data, usually called methods or operations.

Under that definition, Rust is object oriented: structs and enums hold data, and impl blocks provide methods on them.

Those types are not called objects, but they provide the same functionality.

## Encapsulation

Encapsulation means a user of an object should not reach into its internals, and should go through a public API instead.

The only way to interact with an object is through its public API.

Rust controls this with the pub keyword; by default everything else is private.

AveragedCollection is marked pub for other code to use, while its fields remain private. add, remove, and average methods keep the cached average updated.

## See also

- [rust-structs](https://iinventedlight.com/library/notes/rust-structs/)
- [rust-traits](https://iinventedlight.com/library/notes/rust-traits/)
- [rust-trait-objects](https://iinventedlight.com/library/notes/rust-trait-objects/)

## Claims

- id: C1
  claim: There is no single agreed list of features a language needs to be called object oriented.
  source: S1
  evidence: "There is no consensus in the programming community about what features a"

- id: C2
  claim: Under the Gang of Four definition, Rust is object oriented.
  source: S2
  evidence: "Using this definition, Rust is object oriented"

- id: C3
  claim: pub chooses what is public; everything else is private by default.
  source: S2
  evidence: "We can use the `pub` keyword to decide which modules"

## Sources

- [S1] Characteristics of Object-Oriented Languages. The Rust Project Developers. https://doc.rust-lang.org/book/ch18-01-what-is-oo.html . License: MIT OR Apache-2.0. Accessed 2026-11-27.

- [S2] Characteristics of Object-Oriented Languages (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch18-01-what-is-oo.md . License: MIT OR Apache-2.0. Accessed 2026-11-27.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Characteristics of Object-Oriented Languages; The Rust Project Developers, Characteristics of Object-Oriented Languages (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
