diff --git a/src/enums/variant-payloads.md b/src/enums/variant-payloads.md index 056ea580..84c0aad0 100644 --- a/src/enums/variant-payloads.md +++ b/src/enums/variant-payloads.md @@ -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}} ``` + +
+ +* 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. + +