#How to make a type optional?
1 messages · Page 1 of 1 (latest)
you can just do ?T
any type implicitly casts to its optional variant
so if you have a u8 you can just assign some ?u8 variable to it, or you can use @as to make it explicit
const non_optional: u8 = 5;
const optional1: ?u8 = non_optional
const optional2 = @as(?u8, non_optional);
const optional3 = @as(?u8, 10);