aboutsummaryrefslogtreecommitdiff
path: root/src/math/complex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/complex.rs')
-rw-r--r--src/math/complex.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/math/complex.rs b/src/math/complex.rs
index 5b95df4..4d85155 100644
--- a/src/math/complex.rs
+++ b/src/math/complex.rs
@@ -1,4 +1,5 @@
use std::f64::consts::E;
+use std::hash::Hash;
use std::num::ParseFloatError;
use std::str::FromStr;
@@ -75,6 +76,21 @@ impl std::fmt::Display for Complex {
}
}
+impl PartialEq for Complex {
+ fn eq(&self, other: &Self) -> bool {
+ self.real == other.real && self.imag == other.imag
+ }
+}
+
+impl Hash for Complex {
+ fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ format!("{}#{}", self.real, self.imag).hash(state);
+ state.finish();
+ }
+}
+
+impl Eq for Complex {}
+
#[derive(Debug)]
pub struct ComplexParseError;