From 1ca011f69c60903aff458d9862622536d5646b19 Mon Sep 17 00:00:00 2001 From: Emilia Date: Sat, 18 Jan 2025 12:52:39 -0500 Subject: [PATCH] transfer_region refactor 2 Remove `.checked_sub` where logic makes this unnecessary --- plate-tool-lib/src/transfer_region.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plate-tool-lib/src/transfer_region.rs b/plate-tool-lib/src/transfer_region.rs index 9aa0b03..dd81f93 100644 --- a/plate-tool-lib/src/transfer_region.rs +++ b/plate-tool-lib/src/transfer_region.rs @@ -297,12 +297,12 @@ impl TransferRegion { let (s_ul, s_br) = standardize_rectangle(&source_corners.0, &source_corners.1); let s_dims = ( - s_br.row.checked_sub(s_ul.row).unwrap() + 1, - s_br.col.checked_sub(s_ul.col).unwrap() + 1, + s_br.row - s_ul.row + 1, + s_br.col - s_ul.col + 1, ); let d_dims = ( - d_br.row.checked_sub(d_ul.row).unwrap() + 1, - d_br.col.checked_sub(d_ul.col).unwrap() + 1, + d_br.row - d_ul.row + 1, + d_br.col - d_ul.col + 1, ); let number_used_src_wells = ( // Number of used source wells @@ -341,8 +341,8 @@ impl TransferRegion { .into_iter() .filter(|Well { row: x, col: y }| { // Compute row and column offsets once - let row_offset = x.checked_sub(d_ul.row).unwrap(); - let col_offset = y.checked_sub(d_ul.col).unwrap(); + let row_offset = x - d_ul.row; + let col_offset = y - d_ul.col; // Row position check let row_matches = row_offset % row_modulus