Now, we're going to fill in the blanks left in the earlier discussion of functions by talking about parameters and return types.
More about functions
Parameters
Parameters allow us to provide information to a function at the time when we ask it to run.
Asking a function to run is called calling it.
When we define a function, we can tell it the variable names and types we want it to use for receiving parameters, as in the following example:
pub fn set(&mut self, value: i32) {
self.current = value;
}
We'll talk about self in the Implementing behavior for types section of this chapter. For now, ignore it and take a look at value. Here, we've provided a name and data type, just as we would if we were using...