mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-09 12:13:52 +02:00
Update structs.md (#195)
* Update structs.md * Update structs.md * Update structs.md * Update structs.md
This commit is contained in:
parent
1c36b5d771
commit
5792806947
@ -25,3 +25,16 @@ fn main() {
|
||||
println!("{} is {} years old", jackie.name, jackie.age);
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
Key Points:
|
||||
|
||||
* Structs work like in C or C++.
|
||||
* Like in C++, and unlike in C, no typedef is needed to define a type.
|
||||
* Unlike in C++, there is no inheritance between structs.
|
||||
* Methods are defined in an `impl` block, which we will see in following slides.
|
||||
* This may be a good time to let people know there are different types of structs.
|
||||
* Zero-sized structs `e.g., struct Foo;` might be used when implementing a trait on some type but don’t have any data that you want to store in the value itself.
|
||||
* The next slide will introduce Tuple structs.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user