fix lints in fish

This commit is contained in:
tali 2023-04-16 17:56:05 -04:00
parent e673198704
commit a9b86e03c4
3 changed files with 14 additions and 15 deletions

View File

@ -210,8 +210,8 @@ impl SegmentedAStar {
trans: &mut TransTable,
eval: &Evaluator,
) -> Result<u32, Option<&'a Node>> {
let open_set = self.open.get_mut(self.depth);
let cand = open_set.map_or(None, |set| set.pop()).ok_or(None)?;
let open_set = self.open.get_mut(self.depth).ok_or(None)?;
let cand = open_set.pop().ok_or(None)?;
let cand = unsafe { cand.0.as_node() };
if cand.is_terminal() {
@ -230,9 +230,8 @@ impl SegmentedAStar {
eval.evaluate(mat, queue)
};
for suc in cand.expand(arena, trans, evaluate) {
self.open[self.depth].push(suc.into());
}
let expanded = cand.expand(arena, trans, evaluate);
self.open[self.depth].extend(expanded.map(AStarNode::from));
Ok(work)
}

View File

@ -27,7 +27,7 @@ fn copy_matrix<'a>(arena: &'a Arena, matrix: &Mat) -> &'a Mat {
fn copy_queue<'a>(arena: &'a Arena, queue: Queue<'_>) -> Queue<'a> {
Queue {
hold: queue.hold,
next: arena.alloc_slice_copy(&queue.next),
next: arena.alloc_slice_copy(queue.next),
}
}

View File

@ -1,5 +1,6 @@
#![allow(dead_code)]
use core::mem::replace;
use core::ops::Range;
use mino::matrix::{EMPTY_ROW, FULL_ROW};
use mino::{Mat, MatBuf};
@ -125,18 +126,17 @@ fn flood_fill(rows: &mut [u16]) -> Option<(i16, i16, u32)> {
(lx, rx)
}
// list the new columns that should be passed on the stack for the given row and range
// list the new columns that should be pushed on the stack for the given row and range
fn scan(row: u16, lx: i16, rx: i16) -> impl Iterator<Item = i16> {
let mut added = false;
(lx..rx).filter_map(move |x| {
let mut allowed = true;
(lx..rx).filter(move |x| {
if row & (1 << x) != 0 {
added = false;
None
} else if added {
None
// don't push this column since it is occupied, but push the next
// unoccupied column encountered
allowed = true;
false
} else {
added = true;
Some(x)
replace(&mut allowed, false)
}
})
}