1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-25 00:50:26 +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>
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
impl Person {
@ -33,5 +33,9 @@ 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>