v2 / vlib / v / tests / options / option_struct_field_init_test.v
34 lines · 29 sloc · 448 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1pub struct Client {
2pub:
3 token string
4 intents int
5mut:
6 ready bool
7 sequence ?int
8}
9
10enum Intents {
11 foo
12}
13
14pub type IntentsOrInt = Intents | int
15
16@[params]
17pub struct BotConfig {
18pub:
19 intents IntentsOrInt
20}
21
22pub fn bot(token string, config BotConfig) Client {
23 return Client{
24 token: 'Bot ${token}'
25 intents: match config.intents {
26 Intents { int(config.intents) }
27 int { config.intents }
28 }
29 }
30}
31
32fn test_main() {
33 assert true
34}
35