Skip to content

Commit

Permalink
Remove scalar Add and Sub for Vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed Jul 17, 2024
1 parent bb7a944 commit ba74020
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
8 changes: 0 additions & 8 deletions src/vector/commutative.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/// Implements standard commutative operations such as Add and Mul on primitive types.
macro_rules! impl_commutative {
($vector:ident, $component:ident) => {
impl Add<$vector<$component>> for $component {
type Output = $vector<$component>;

fn add(self, rhs: $vector<$component>) -> Self::Output {
<$vector<$component> as Add<$component>>::add(rhs, self)
}
}

impl Mul<$vector<$component>> for $component {
type Output = $vector<$component>;

Expand Down
28 changes: 0 additions & 28 deletions src/vector/vector2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,6 @@ where
}
}

impl<C> Add<C> for Vector2d<C>
where
C: Component,
{
type Output = Self;

fn add(self, rhs: C) -> Self {
Self {
x: self.x + rhs,
y: self.y + rhs,
}
}
}

impl<C> Sub for Vector2d<C>
where
C: Component,
Expand All @@ -242,20 +228,6 @@ where
}
}

impl<C> Sub<C> for Vector2d<C>
where
C: Component,
{
type Output = Self;

fn sub(self, rhs: C) -> Self {
Self {
x: self.x - rhs,
y: self.y - rhs,
}
}
}

impl<C> Mul<C> for Vector2d<C>
where
C: Component,
Expand Down
30 changes: 0 additions & 30 deletions src/vector/vector3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,6 @@ where
}
}

impl<C> Add<C> for Vector3d<C>
where
C: Component,
{
type Output = Self;

fn add(self, rhs: C) -> Self {
Self {
x: self.x + rhs,
y: self.y + rhs,
z: self.z + rhs,
}
}
}

impl<C> Sub for Vector3d<C>
where
C: Component,
Expand All @@ -255,21 +240,6 @@ where
}
}

impl<C> Sub<C> for Vector3d<C>
where
C: Component,
{
type Output = Self;

fn sub(self, rhs: C) -> Self {
Self {
x: self.x - rhs,
y: self.y - rhs,
z: self.z - rhs,
}
}
}

/// Compute the cross product of two vectors
impl<C> Mul for Vector3d<C>
where
Expand Down

0 comments on commit ba74020

Please sign in to comment.