I am not sure that I am understanding how the var return type work, I have this code:
proc findComponent*(e: var Entity, T: typedesc): Option[var T] =
for c in e.components.mitems:
if c of T:
result = some(T(c))
result = none(var T)
I am trying to find a component in e, then return an var of that component, I get this error:
Error: type mismatch: got <Option[physics.TransformComponent]> but expected 'Option[var None]'
What does the var None in the return type mean? Is it just not possible to wrap a var in an Option?Is it just not possible to wrap a var in an Option?
Yep, it's not possible to put var T fields in objects (though it might be possible in the future). The compiler does allow putting them in tuples though it doesn't behave very well (what if you don't initialize the var T?).