aboutsummaryrefslogtreecommitdiff
path: root/src/math/polygon_graph.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/polygon_graph.rs')
-rw-r--r--src/math/polygon_graph.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/math/polygon_graph.rs b/src/math/polygon_graph.rs
index 7721cbf..14b2b0d 100644
--- a/src/math/polygon_graph.rs
+++ b/src/math/polygon_graph.rs
@@ -9,7 +9,7 @@ struct Node<T: Scalar + Copy> {
}
struct EdgeIterator<'a, T: Scalar + Copy> {
- nodes: &'a Vec<Node<T>>,
+ nodes: &'a [Node<T>],
pos: (usize, usize),
}
@@ -39,7 +39,7 @@ fn find_node<T: Scalar + Copy + PartialOrd>(
}
impl<'a, T: Scalar + Copy> EdgeIterator<'a, T> {
- pub fn new(nodes: &'a Vec<Node<T>>) -> Self {
+ pub fn new(nodes: &'a [Node<T>]) -> Self {
Self { nodes, pos: (0, 0) }
}
}
@@ -99,11 +99,7 @@ impl<T: Scalar + Copy + PartialOrd> PolygonGraph<T> {
pub fn has_edge(&self, from: &Vec2<T>, to: &Vec2<T>) -> bool {
// Binary search the starting and then the end node.
if let Ok(from) = find_node(&self.nodes, from) {
- if let Ok(_) = find_vec2(&self.nodes[from].adjacent, to) {
- true
- } else {
- false
- }
+ find_vec2(&self.nodes[from].adjacent, to).is_ok()
} else {
false
}