diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-07 22:27:59 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-07 22:27:59 -0700 |
commit | 204ee3854d3d45338ed9f1659d44f23062bfac77 (patch) | |
tree | 8b58d90d7b9ad367f6be1f336cd6146f6417e87c /src/number.rs | |
parent | b8bb816d72217c1afdb18858481db737e52a4e7f (diff) | |
download | hope-main.tar.gz hope-main.zip |
Diffstat (limited to 'src/number.rs')
-rw-r--r-- | src/number.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/number.rs b/src/number.rs index 5ea7949..d40e50a 100644 --- a/src/number.rs +++ b/src/number.rs @@ -1,7 +1,7 @@ use std::cmp::max; use std::convert::TryFrom; use std::num::TryFromIntError; -use std::ops::Add; +use std::ops::{Add, Mul}; #[derive(Clone)] pub struct Number { @@ -59,3 +59,17 @@ impl Add for Number { } } } + +impl Mul for Number { + type Output = Number; + + fn mul(self, rhs: Self) -> Self::Output { + if self.integer_part.len() > 1 || rhs.integer_part.len() > 1 { + todo!() + } else { + Number { + integer_part: vec![self.integer_part[0] * rhs.integer_part[0]] + } + } + } +} |