v2 / vlib / v / tests / conditions / ifs / if_smartcast_likely_test.v
17 lines · 14 sloc · 347 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1// fixes https://github.com/vlang/v/issues/11485 based on code example by https://github.com/Wertzui123
2interface IExample {
3}
4
5struct Example {
6 value string
7}
8
9fn test_if_smartcast_likely() {
10 print_value(Example{ value: 'Hello' })
11}
12
13fn print_value(example IExample) {
14 if _likely_(example is Example) {
15 print('Value: ' + example.value)
16 }
17}
18