summaryrefslogtreecommitdiffstats
path: root/src/metric
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-05-11 11:33:45 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-05-11 11:33:45 -0400
commitadaafdd7043507cbceae65e78c38954e47103b5c (patch)
treec8e2b62b2f39e0f2dc7908ca613df92dd7b541c1 /src/metric
parent825515439247853af3714d3135051a83bd84d2e0 (diff)
downloadkd-forest-adaafdd7043507cbceae65e78c38954e47103b5c.tar.xz
Fix some clippy lints
Diffstat (limited to 'src/metric')
-rw-r--r--src/metric/forest.rs18
-rw-r--r--src/metric/soft.rs10
2 files changed, 28 insertions, 0 deletions
diff --git a/src/metric/forest.rs b/src/metric/forest.rs
index 47eb413..887ff12 100644
--- a/src/metric/forest.rs
+++ b/src/metric/forest.rs
@@ -50,6 +50,24 @@ where
}
len
}
+
+ /// Check if this forest is empty.
+ pub fn is_empty(&self) -> bool {
+ if !self.buffer.is_empty() {
+ return false;
+ }
+
+ self.trees.iter().flatten().next().is_none()
+ }
+}
+
+impl<T, U> Default for Forest<U>
+where
+ U: FromIterator<T> + IntoIterator<Item = T>,
+{
+ fn default() -> Self {
+ Self::new()
+ }
}
impl<T, U> Extend<T> for Forest<U>
diff --git a/src/metric/soft.rs b/src/metric/soft.rs
index 0d7dcdb..d443bfd 100644
--- a/src/metric/soft.rs
+++ b/src/metric/soft.rs
@@ -82,6 +82,16 @@ where
}
}
+impl<T, U> Default for SoftSearch<U>
+where
+ T: SoftDelete,
+ U: FromIterator<T> + IntoIterator<Item = T>,
+{
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl<T, U: Extend<T>> Extend<T> for SoftSearch<U> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
self.0.extend(iter);