Pass by Reference
Understand how to pass arguments by reference in Rust functions. This lesson demonstrates mutable references, dereferencing, and updating values within a function to manage data effectively.
We'll cover the following...
We'll cover the following...
Arguments Pass by Reference
When we want the called function to make changes to the parameters such that the changes are seen by the calling function when the call returns. The mechanism to do this is called pass arguments by reference.
Syntax
The general syntax of passing arguments by reference is:
Example
The following example makes a function square() that takes a number n which is being passed by reference as a parameter to the function and prints the square of the function within the function.
...