1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-25 08:53:01 +02:00

Speaker Notes for Field Shorthand (#198)

* Speaker Notes for Field Shorthand

* Update field-shorthand.md
This commit is contained in:
Charisee Chiw 2023-02-22 06:55:29 -08:00 committed by GitHub
parent 8ee637d886
commit 3f6bd6aa14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@ fn main() {
<details> <details>
The `new` function could be written using `Self` as a type, as it is interchangeable with the struct type name * The `new` function could be written using `Self` as a type, as it is interchangeable with the struct type name
```rust,ignore ```rust,ignore
impl Person { impl Person {
@ -34,4 +34,8 @@ impl Person {
} }
``` ```
* Methods are defined in the `impl` block.
* Use struct update syntax to define a new structure using `peter`. Note that the variable `peter` will no longer be accessible afterwards.
* Use `{:#?}` when printing structs to request the `Debug` representation.
</details> </details>