diff options
Diffstat (limited to 'src/vector.rs')
| -rw-r--r-- | src/vector.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/vector.rs b/src/vector.rs index 366812f..56d1817 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -18,6 +18,12 @@ impl DerefMut for FileVector { } } +impl Default for FileVector { + fn default() -> Self { + Self::new() + } +} + impl FileVector { pub fn new() -> Self { Self { data : HashMap::new() } @@ -39,7 +45,7 @@ impl FileVector { Self { data } } - pub fn to_string(&self) -> String { + pub fn stringify(&self) -> String { let mut hex = String::new(); for (i, v) in self.data.iter() { @@ -53,7 +59,7 @@ impl FileVector { pub fn scalar_product(a : &FileVector, b : &FileVector) -> u64 { let mut c = 0; for (i, x) in a.iter() { - c += x * (b.get(i).unwrap_or_else(|| &0)); + c += x * (b.get(i).unwrap_or(&0)); } c } |