I am looking for ways to create a Vec
of structs that have fields implementing a specific trait, more specifically the following struct:
struct Animation<T: Add> {
channel: TypeId,// channel/component to animate
path: String, // string
from: T, // T is a type that implements the ADD trait ie : can be either float or vec2, vec4, vec4 etc
to: T, // T is a type that implements the ADD trait ie : can be either float or vec2, vec4, vec4 etc , same as from
duration: u64,
easing: String,
repeat: i16
}
I am still new to Rust so sorry if this is obvious
- How would you use
Box<Animation>
for dynamic dispatch in this case? - defining an enum that has a variant for each type (
f32
,vec3
) works but seems very verbose.