Clippy
This commit is contained in:
@@ -125,7 +125,7 @@ impl Line {
|
|||||||
vertical = other;
|
vertical = other;
|
||||||
regular = self;
|
regular = self;
|
||||||
}
|
}
|
||||||
return Some(Point::from_line_x(®ular, vertical.p1.x));
|
return Some(Point::from_line_x(regular, vertical.p1.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate x coordinate of intersection point between both lines
|
// Calculate x coordinate of intersection point between both lines
|
||||||
@@ -133,9 +133,9 @@ impl Line {
|
|||||||
// Solve for x: x = (b1 - b2) / (m2 - m1)
|
// Solve for x: x = (b1 - b2) / (m2 - m1)
|
||||||
let x = (self.b - other.b) / (other.m - self.m);
|
let x = (self.b - other.b) / (other.m - self.m);
|
||||||
if self.m.abs() < other.m.abs() {
|
if self.m.abs() < other.m.abs() {
|
||||||
Some(Point::from_line_x(&self, x))
|
Some(Point::from_line_x(self, x))
|
||||||
} else {
|
} else {
|
||||||
Some(Point::from_line_x(&other, x))
|
Some(Point::from_line_x(other, x))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ pub struct NodeStorage {
|
|||||||
final_node: Option<NodePtr>,
|
final_node: Option<NodePtr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type NodeStorageIterator<'a> = std::iter::Chain<
|
||||||
|
std::slice::Iter<'a, Rc<RefCell<Node>>>,
|
||||||
|
std::option::Iter<'a, Rc<RefCell<Node>>>,
|
||||||
|
>;
|
||||||
|
|
||||||
impl NodeStorage {
|
impl NodeStorage {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
@@ -79,7 +84,7 @@ impl NodeStorage {
|
|||||||
self.regular_nodes.push(node);
|
self.regular_nodes.push(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_edges(&mut self, node: &NodePtr, walls: &Vec<LineSegment>) {
|
fn initialize_edges(&mut self, node: &NodePtr, walls: &[LineSegment]) {
|
||||||
if node.borrow().final_edge.is_none() {
|
if node.borrow().final_edge.is_none() {
|
||||||
let final_edge = self
|
let final_edge = self
|
||||||
.final_node
|
.final_node
|
||||||
@@ -118,7 +123,7 @@ impl NodeStorage {
|
|||||||
node.borrow_mut().edges = Some(edges);
|
node.borrow_mut().edges = Some(edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collides_with_wall(&self, line: &LineSegment, walls: &Vec<LineSegment>) -> bool {
|
fn collides_with_wall(&self, line: &LineSegment, walls: &[LineSegment]) -> bool {
|
||||||
walls.iter().any(|wall| line.intersection(wall).is_some())
|
walls.iter().any(|wall| line.intersection(wall).is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,12 +133,7 @@ impl NodeStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(
|
pub fn iter(&self) -> NodeStorageIterator {
|
||||||
&self,
|
|
||||||
) -> std::iter::Chain<
|
|
||||||
std::slice::Iter<'_, Rc<RefCell<Node>>>,
|
|
||||||
std::option::Iter<'_, Rc<RefCell<Node>>>,
|
|
||||||
> {
|
|
||||||
self.regular_nodes.iter().chain(self.final_node.iter())
|
self.regular_nodes.iter().chain(self.final_node.iter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user