mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-04 03:25:08 +02:00
Add speaker notes for variant-payloads.md
This commit is contained in:
parent
e29c3bfb99
commit
c91cc629d5
@ -6,3 +6,11 @@ You can define richer enums where the variants carry data. You can then use the
|
||||
```rust,editable
|
||||
{{#include ../../third_party/rust-by-example/webevent.rs}}
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
* In the above example, accessing the `char` in `KeyPress`, or `x` and `y` in `Click` only works within a `match` statement.
|
||||
* `match` inspects a hidden discriminant field in the `enum`.
|
||||
* `WebEvent::Click { ... }` is not exactly the same as `WebEvent::Click(Click)` with a top level `struct Click { ... }`. The inlined version cannot implement traits, for example.
|
||||
|
||||
</details>
|
||||
|
Loading…
Reference in New Issue
Block a user