From 1e14ff24b00f809f8ed336160e05aba34b94ffb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Mon, 31 Jan 2022 23:31:29 +0100 Subject: [PATCH] Implement more clippy suggestions --- rust/src/geometry.rs | 8 +++++++- rust/src/js_api.rs | 4 +++- rust/src/ptr_indexed_hash_set.rs | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/rust/src/geometry.rs b/rust/src/geometry.rs index 711cefa..60d24ae 100644 --- a/rust/src/geometry.rs +++ b/rust/src/geometry.rs @@ -14,7 +14,7 @@ extern "C" { } #[wasm_bindgen] -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone)] pub struct Point { pub x: f64, pub y: f64, @@ -37,6 +37,12 @@ impl Point { impl Eq for Point {} +impl PartialEq for Point { + fn eq(&self, other: &Self) -> bool { + self.x == other.x && self.y == other.y + } +} + impl Hash for Point { fn hash(&self, hasher: &mut H) { self.x.to_bits().hash(hasher); diff --git a/rust/src/js_api.rs b/rust/src/js_api.rs index f016af1..9ed2773 100644 --- a/rust/src/js_api.rs +++ b/rust/src/js_api.rs @@ -100,7 +100,9 @@ pub fn free(pathfinder: Pathfinder) { #[allow(dead_code)] #[wasm_bindgen(js_name=findPath)] pub fn find_path(pathfinder: &mut Pathfinder, from: JsPoint, to: JsPoint) -> Option { - pathfinder.find_path(from.into(), to.into()).map(|first_node| first_node.iter_path().map(JsValue::from).collect()) + pathfinder + .find_path(from.into(), to.into()) + .map(|first_node| first_node.iter_path().map(JsValue::from).collect()) } #[allow(dead_code)] diff --git a/rust/src/ptr_indexed_hash_set.rs b/rust/src/ptr_indexed_hash_set.rs index deef758..c12aa2d 100644 --- a/rust/src/ptr_indexed_hash_set.rs +++ b/rust/src/ptr_indexed_hash_set.rs @@ -3,6 +3,7 @@ use std::collections::hash_set; use std::hash::{Hash, Hasher}; use std::rc::Rc; +#[derive(Default)] pub struct PtrIndexedHashSet(FxHashSet>); impl PtrIndexedHashSet {