Mutating in Place with inout
Let a function change the caller's value.
Sometimes You Must Change It
Borrowing only lets you read. But sometimes a function needs to actually modify the caller's value, like bumping a counter. ✏️
Meet inout
The inout convention gives a function mutable access. Changes you make inside are reflected back in the caller's variable.
All lessons in this course
- Borrowing Arguments Read-Only
- Mutating in Place with inout
- Taking Ownership with owned
- The Transfer Operator