v2 / vlib / v / tests / aliases / alias_option_test.v
15 lines · 12 sloc · 236 bytes · 87340bcca2aa7f7cb6b524d6573a08b52ed1401b
Raw
1module main
2
3// Test option type alias
4pub type MaybeInt = ?int
5
6pub fn is_some(val MaybeInt) bool {
7 return val != none
8}
9
10fn test_alias_option() {
11 v := ?int(42)
12 result := is_some(v)
13 println('Has value: ${result}')
14 assert result
15}
16