Initial commit
This commit is contained in:
commit
00d68d5165
13 changed files with 1129 additions and 0 deletions
26
src/tuple.rs
Normal file
26
src/tuple.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use std::ops::{Add, Mul};
|
||||
use num_traits::Inv;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
pub struct Tuple<A, B>(pub A, pub B);
|
||||
|
||||
impl<A, B> Add for Tuple<A, B> where A: Add<A, Output=A>, B: Add<B, Output=B> {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: Self) -> Self {
|
||||
Self(self.0+rhs.0, self.1+rhs.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> Mul for Tuple<A, B> where A: Mul<A, Output=A>, B: Mul<B, Output=B> {
|
||||
type Output = Self;
|
||||
fn mul(self, rhs: Self) -> Self {
|
||||
Self(self.0*rhs.0, self.1*rhs.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A,B> Inv for Tuple<A, B> where A: Inv<Output=A>, B: Inv<Output=B> {
|
||||
type Output = Self;
|
||||
fn inv(self) -> Self {
|
||||
Self(self.0.inv(), self.1.inv())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue