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:
parent
8ee637d886
commit
3f6bd6aa14
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user