Properties
prop defines computed properties through get() and optional set(v). Externally, they are used like regular fields, but read and write operations execute custom logic behind the scenes. Properties can implement access control, data validation, lazy computation, and other features.
Properties without the mut modifier can only define get() and are read-only properties. Properties with mut must define both get() and set(v) and are read-write properties. Computed properties don't occupy additional storage space; they are dynamically calculated based on other data.
The Temperature class below uses Celsius as the actual stored field, with Fahrenheit derived through a computed property. When Celsius changes, Fahrenheit automatically updates—because it recalculates on each access.
Accessing the property itself in getter and setter will cause infinite recursion, similar to function recursion.
Try adding a set(v) to the fahrenheit property: convert Fahrenheit back to Celsius for storage.