by anderskaseorg · 7y ago · 0 comments
You can cut down on a lot of that by implementing basic operations (Add, Mul, etc.) for both value and reference types.
impl Add<Vector3> for Vector3 { … }
impl Add<&Vector3> for Vector3 { … }
impl Add<Vector3> for &Vector3 { … }
impl Add<&Vector3> for &Vector3 { … }
(The first three can delegate to the last one, unless there are value-specific optimizations you want to apply.)A crate with a derive macro for example?
impl<T> Add<T> for &Vector3 where T: Borrow<Vector3>