Skip to content

web search done right

fix clippy warnings

Mikkel Denker84b32e56e3f3
diff --git a/core/src/crawler/crawl_db.rs b/core/src/crawler/crawl_db.rs
index a7b92242..19aea836 100644
--- a/core/src/crawler/crawl_db.rs
+++ b/core/src/crawler/crawl_db.rs
@@ -58,15 +58,13 @@ impl<T> Eq for SampledItem<T> {}
impl<T> PartialOrd for SampledItem<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.priority.partial_cmp(&other.priority)
+ Some(self.cmp(other))
}
}
impl<T> Ord for SampledItem<T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.priority
- .partial_cmp(&other.priority)
- .unwrap_or(std::cmp::Ordering::Equal)
+ self.priority.total_cmp(&other.priority)
}
}
diff --git a/core/src/entrypoint/indexer.rs b/core/src/entrypoint/indexer.rs
index 26ce51e3..9e53855d 100644
--- a/core/src/entrypoint/indexer.rs
+++ b/core/src/entrypoint/indexer.rs
@@ -186,7 +186,7 @@ pub fn process_job(job: &Job, worker: &IndexingWorker) -> Index {
.map(|edge| edge.label.loaded().unwrap())
.collect()
})
- .unwrap_or_else(Vec::new);
+ .unwrap_or_default();
let mut page_centrality = 0.0;
diff --git a/core/src/query/union.rs b/core/src/query/union.rs
index 879f107d..bd9a6dd8 100644
--- a/core/src/query/union.rs
+++ b/core/src/query/union.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-use std::{cell::RefCell, cmp::Ordering};
+use std::cell::RefCell;
use min_max_heap::MinMaxHeap;
use tantivy::{
@@ -29,13 +29,13 @@ struct DocsetHead<T> {
impl<T> PartialOrd for DocsetHead<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.min_doc.partial_cmp(&other.min_doc)
+ Some(self.cmp(other))
}
}
impl<T> Ord for DocsetHead<T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.partial_cmp(other).unwrap_or(Ordering::Equal)
+ self.min_doc.cmp(&other.min_doc)
}
}
diff --git a/core/src/similar_sites.rs b/core/src/similar_sites.rs
index d49a564a..4b13ba84 100644
--- a/core/src/similar_sites.rs
+++ b/core/src/similar_sites.rs
@@ -35,7 +35,7 @@ struct ScoredNodeID {
impl PartialOrd for ScoredNodeID {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.score.partial_cmp(&other.score)
+ Some(self.cmp(other))
}
}
@@ -47,7 +47,7 @@ impl PartialEq for ScoredNodeID {
impl Ord for ScoredNodeID {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.partial_cmp(other).unwrap_or(std::cmp::Ordering::Equal)
+ self.score.total_cmp(&other.score)
}
}
diff --git a/core/src/summarizer.rs b/core/src/summarizer.rs
index cd6983a3..f571a8f0 100644
--- a/core/src/summarizer.rs
+++ b/core/src/summarizer.rs
@@ -15,7 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use std::{
- cmp::{Ordering, Reverse},
+ cmp::Reverse,
collections::{BinaryHeap, VecDeque},
ops::Range,
path::Path,
@@ -62,13 +62,13 @@ struct CandidatePassage<'a> {
impl<'a> PartialOrd for CandidatePassage<'a> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.score.partial_cmp(&other.score)
+ Some(self.cmp(other))
}
}
impl<'a> Ord for CandidatePassage<'a> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.partial_cmp(other).unwrap_or(Ordering::Equal)
+ self.score.total_cmp(&other.score)
}
}