1
0
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:
Fabian Bornhofen 2023-01-10 16:46:57 +01:00
parent e29c3bfb99
commit c91cc629d5

View File

@ -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>