Skip to content

Commit

Permalink
Stabilized let else formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Oct 5, 2023
1 parent 4fa46d3 commit 361b5d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions mapf-viz/src/spatial_canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ impl<Message, Program: SpatialCanvasProgram<Message>> SpatialCanvas<Message, Pro
}

pub fn camera_bounds(&self) -> InclusionZone {
let Some(bounds) = &self.bounds else { return InclusionZone::Empty };
let Some(s_inv) = Transform::scale(self.zoom, -self.zoom).inverse() else { return InclusionZone::Empty };
let Some(bounds) = &self.bounds else {
return InclusionZone::Empty;
};
let Some(s_inv) = Transform::scale(self.zoom, -self.zoom).inverse() else {
return InclusionZone::Empty;
};
let bound_center = Point::new(bounds.width / 2.0, bounds.height / 2.0);
let p0 = s_inv.transform_point(bound_center - self.offset) - bound_center / self.zoom;
let p1 = iced::Point::new(
Expand All @@ -182,7 +186,9 @@ impl<Message, Program: SpatialCanvasProgram<Message>> SpatialCanvas<Message, Pro
}

pub fn fit_to_zone(&mut self, zone: InclusionZone) -> bool {
let Some(bounds) = &mut self.bounds else { return false };
let Some(bounds) = &mut self.bounds else {
return false;
};

if let InclusionZone::Some { lower, upper } = zone {
let x_zoom = bounds.width / (upper.x - lower.x);
Expand Down
12 changes: 9 additions & 3 deletions mapf/src/negotiation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ impl NegotiationCloser {

pub fn status<'a>(&'a self, node: &NegotiationNode) -> ClosedStatus<'a, ()> {
let mut key_iter = node.keys.iter();
let Some(first_key) = key_iter.next() else { return ClosedStatus::Open };
let Some(first_key) = key_iter.next() else {
return ClosedStatus::Open;
};

let mut candidates: HashSet<usize> = HashSet::from_iter(
self.closed_set
Expand All @@ -528,7 +530,9 @@ impl NegotiationCloser {
break;
}

let Some(new_candidates) = self.closed_set.get(next_key) else { return ClosedStatus::Open };
let Some(new_candidates) = self.closed_set.get(next_key) else {
return ClosedStatus::Open;
};
candidates.retain(|c| new_candidates.contains(c));
}

Expand Down Expand Up @@ -862,7 +866,9 @@ fn reconsider_negotiations(
let mut merge_old_negotiation_into_new: HashMap<usize, HashSet<usize>> = HashMap::new();
for (i, negotiation) in &new_negotiations {
for agent in &negotiation.participants {
let Some(n_prev) = previous_negotiation_of_agent.get(agent).cloned() else { continue };
let Some(n_prev) = previous_negotiation_of_agent.get(agent).cloned() else {
continue;
};
merge_old_negotiation_into_new
.entry(n_prev)
.or_default()
Expand Down

0 comments on commit 361b5d6

Please sign in to comment.