Skip to content

Instantly share code, notes, and snippets.

@jeandudey
Created February 10, 2017 02:31
Show Gist options
  • Save jeandudey/74ff13d692932b18623a0d07d796533b to your computer and use it in GitHub Desktop.
Save jeandudey/74ff13d692932b18623a0d07d796533b to your computer and use it in GitHub Desktop.
impl<'a> std::ops::Sub<Vec3> for &'a Vec3 {
type Output = Vec3;
fn sub(self, other: Vec3) -> Vec3 {
let mut output = Vec3::new([0f64; 3]);
for index in 0..3 {
output.vector[index] = self.vector[index] - other.vector[index];
}
return output;
}
}
impl<'a> std::ops::Sub<&'a Vec3> for Vec3 {
type Output = Vec3;
fn sub(self, other: &'a Vec3) -> Vec3 {
let mut output = Vec3::new([0f64; 3]);
for index in 0..3 {
output.vector[index] = self.vector[index] - other.vector[index];
}
return output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment