keyframe
keyframe copied to clipboard
Why must `Keyframe<T>.value()` be `T: Copy`?
Why must T be Copy? How can one access a value in a keyframe with non-copy types?
I believe the motivation here must be to avoid unnecessary allocations. This makes sense as allocating on each tween would be crippling for performance.
Perhaps instead of returning an owned type, the caller to ease()
could pass an output: &mut Self
? That would allow for tweening types that are non-copy, by writing into the output
.
I believe the reason for ease()
working with values rather than references is that the former is better for primitive types. An f32
is smaller than a pointer on 64-bit processors, and it should be slightly faster since no dereferencing is needed.
Tweening primitive values or small structures seemed like the most common use case to me at the time, but the current design obviously has some downsides for larger structures or structures that can't be copied.