© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
C. MilanesiBeginning Rusthttps://doi.org/10.1007/978-1-4842-7208-4_18

18. Data Encapsulation

Carlo Milanesi1  
(1)
Bergamo, Italy
 
In this chapter, you will learn:
  • Why the dot notation for calling a function is more convenient than the functional notation

  • How to use the impl and self keywords to declare functions that can be invoked using the dot notation

  • How to encapsulate function declarations in modules, selecting which functions declared in a module should be accessible from other modules

  • How to create a hierarchy of modules, and how to access any function in such hierarchy

  • How to define type aliases

The Need for Methods

We already saw that there are two possible ...

Get Beginning Rust: Get Started with Rust 2021 Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.