1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Currently `DecodeScalar` derive is only implemented for enums
# Enums
Only enums that contain no data are supported:
```rust
#[derive(knuffel::DecodeScalar)]
enum Color {
Red,
Blue,
Green,
InfraRed,
}
```
This will match scalar values in `kebab-case`. For example, this node decoder:
```
# #[derive(knuffel::DecodeScalar)]
# enum Color { Red, Blue, Green, InfraRed }
#[derive(knuffel::Decode)]
struct Document {
#[knuffel(child, unwrap(arguments))]
all_colors: Vec<Color>,
}
```
Can be populated from the following text:
```kdl
all-colors "red" "blue" "green" "infra-red"
```
|