From be2bb2d4c5179a4395607bbe1b34aba389b70b93 Mon Sep 17 00:00:00 2001 From: Charisee Chiw <charisee.chiw@gmail.com> Date: Mon, 23 Jan 2023 03:53:33 -0800 Subject: [PATCH] Speaker notes for Method example (#203) * Speaker notes for Method example * Update example.md --- src/methods/example.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/methods/example.md b/src/methods/example.md index aea2c9cf..7dd80c27 100644 --- a/src/methods/example.md +++ b/src/methods/example.md @@ -39,3 +39,14 @@ fn main() { race.finish(); } ``` + +<details> + +Key Points: +* All four methods here use a different method receiver. + * You can point out how that changes what the function can do with the variable values and if/how it can be used again in `main`. + * You can showcase the error that appears when trying to call `finish` twice. +* Note, that although the method receivers are different, the non-static functions are called the same way in the main body. Rust enables automatic referencing and dereferencing when calling methods. Rust automatically adds in the `&`, `*`, `muts` so that that object matches the method signature. +* You might point out that `print_laps` is using a vector that is iterated over. We describe vectors in more detail in the afternoon. + +</details>