Closed qm3ster closed 2 years ago
Yes. Newtypes are useful if you need to restrict or enforce some new invariant for a datatype.
However if only using newtypes for type uniqueness in an ECS and having to do Into
and From
it can become problematic.
The idea behind flex is to enforce the types which are valid components so that you can use a e.g Vec3
for both position and velocity and add them together without having to convert one to the other.
You can still use newtypes and name them as a component, as a bonus, the compiler will enforce that you actually use the correct type when inserting it so that oyu don't accidentally use a &'static str
where String
was expected.
I am still early in the development of this plugin, and the plan is to allow complex and dynamic components as well.
But what if newtype good? 🤔