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