cargo fmt

This commit is contained in:
Henry Schimke
2023-01-27 15:14:01 -06:00
parent d2728e0414
commit 58e6827e89
3 changed files with 86 additions and 83 deletions

View File

@@ -231,7 +231,7 @@ impl BitMatrix {
let start_x = x - box_size / 2; let start_x = x - box_size / 2;
let end_x = x + box_size / 2; let end_x = x + box_size / 2;
let start_y = y - box_size / 2; let start_y = y - box_size / 2;
let end_y = y+ box_size / 2; let end_y = y + box_size / 2;
for get_x in start_x..=end_x { for get_x in start_x..=end_x {
for get_y in start_y..=end_y { for get_y in start_y..=end_y {
@@ -239,10 +239,10 @@ impl BitMatrix {
} }
} }
let total_set = matrix.iter().filter(|bit| **bit ).count(); let total_set = matrix.iter().filter(|bit| **bit).count();
if (total_set as f32 / matrix.len() as f32) >=0.5 { if (total_set as f32 / matrix.len() as f32) >= 0.5 {
Some(true) Some(true)
}else { } else {
Some(false) Some(false)
} }
} }

View File

@@ -825,9 +825,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, topl_p1, rotation); let p1_rot = get_point(circle.center, topl_p1, rotation);
let p2_rot = get_point(circle.center, topl_p2, rotation); let p2_rot = get_point(circle.center, topl_p2, rotation);
let p3_rot = get_point(circle.center, topl_p3, rotation); let p3_rot = get_point(circle.center, topl_p3, rotation);
let found_tl = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_tl = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_tl { if !found_tl {
continue; continue;
} }
@@ -838,9 +838,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, topr_p1, rotation); let p1_rot = get_point(circle.center, topr_p1, rotation);
let p2_rot = get_point(circle.center, topr_p2, rotation); let p2_rot = get_point(circle.center, topr_p2, rotation);
let p3_rot = get_point(circle.center, topr_p3, rotation); let p3_rot = get_point(circle.center, topr_p3, rotation);
let found_tr = !image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_tr = !image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& !image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && !image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_tr { if !found_tr {
continue; continue;
} }
@@ -851,9 +851,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, l_p1, rotation); let p1_rot = get_point(circle.center, l_p1, rotation);
let p2_rot = get_point(circle.center, l_p2, rotation); let p2_rot = get_point(circle.center, l_p2, rotation);
let p3_rot = get_point(circle.center, l_p3, rotation); let p3_rot = get_point(circle.center, l_p3, rotation);
let found_l = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_l = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_l { if !found_l {
continue; continue;
} }
@@ -864,9 +864,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, r_p1, rotation); let p1_rot = get_point(circle.center, r_p1, rotation);
let p2_rot = get_point(circle.center, r_p2, rotation); let p2_rot = get_point(circle.center, r_p2, rotation);
let p3_rot = get_point(circle.center, r_p3, rotation); let p3_rot = get_point(circle.center, r_p3, rotation);
let found_r = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_r = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_r { if !found_r {
continue; continue;
} }
@@ -877,9 +877,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, bottoml_p1, rotation); let p1_rot = get_point(circle.center, bottoml_p1, rotation);
let p2_rot = get_point(circle.center, bottoml_p2, rotation); let p2_rot = get_point(circle.center, bottoml_p2, rotation);
let p3_rot = get_point(circle.center, bottoml_p3, rotation); let p3_rot = get_point(circle.center, bottoml_p3, rotation);
let found_bl = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_bl = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_bl { if !found_bl {
continue; continue;
} }
@@ -890,9 +890,9 @@ fn attempt_rotation_box(
let p1_rot = get_point(circle.center, bottomr_p1, rotation); let p1_rot = get_point(circle.center, bottomr_p1, rotation);
let p2_rot = get_point(circle.center, bottomr_p2, rotation); let p2_rot = get_point(circle.center, bottomr_p2, rotation);
let p3_rot = get_point(circle.center, bottomr_p3, rotation); let p3_rot = get_point(circle.center, bottomr_p3, rotation);
let found_br = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32,3)? let found_br = image.try_get_area(p1_rot.0 as u32, p1_rot.1 as u32, 3)?
&& !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32,3)? && !image.try_get_area(p2_rot.0 as u32, p2_rot.1 as u32, 3)?
&& image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32,3)?; && image.try_get_area(p3_rot.0 as u32, p3_rot.1 as u32, 3)?;
if !found_br { if !found_br {
continue; continue;
} }

View File

@@ -124,7 +124,10 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
.filter(|r| r.is_ok()) // Get rid of Err variants for Result<DirEntry> .filter(|r| r.is_ok()) // Get rid of Err variants for Result<DirEntry>
.map(|r| r.unwrap().path()) // This is safe, since we only have the Ok variants .map(|r| r.unwrap().path()) // This is safe, since we only have the Ok variants
.filter(|r| r.is_file()) // Filter out non-folders .filter(|r| r.is_file()) // Filter out non-folders
.filter(|r| r.extension().is_some() && POSSIBLE_EXTENSIONS.contains(r.extension().unwrap().to_str().unwrap())) .filter(|r| {
r.extension().is_some()
&& POSSIBLE_EXTENSIONS.contains(r.extension().unwrap().to_str().unwrap())
})
// .map(|r| r.into_boxed_path()) // .map(|r| r.into_boxed_path())
.collect::<Vec<PathBuf>>(); .collect::<Vec<PathBuf>>();