From 1c94af40eef42cd190c51d4b8820ff635d1e423d Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Thu, 29 Dec 2022 17:46:09 -0600 Subject: [PATCH] more std::mem::swap changes --- src/datamatrix/detector/detector.rs | 8 ++------ src/qrcode/detector/detector.rs | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/datamatrix/detector/detector.rs b/src/datamatrix/detector/detector.rs index e54410e..19b9680 100644 --- a/src/datamatrix/detector/detector.rs +++ b/src/datamatrix/detector/detector.rs @@ -367,12 +367,8 @@ impl Detector { let steep = (toY - fromY).abs() > (toX - fromX).abs(); if steep { - let mut temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; + std::mem::swap(&mut fromX, &mut fromY); + std::mem::swap(&mut toX, &mut toY); } let dx = (toX - fromX).abs(); diff --git a/src/qrcode/detector/detector.rs b/src/qrcode/detector/detector.rs index fe5fe6b..796acb1 100644 --- a/src/qrcode/detector/detector.rs +++ b/src/qrcode/detector/detector.rs @@ -385,12 +385,8 @@ impl Detector { // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm let steep = (toY as i64 - fromY as i64).abs() > (toX as i64 - fromX as i64).abs(); if steep { - let mut temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; + std::mem::swap(&mut fromX, &mut fromY); + std::mem::swap(&mut toX, &mut toY); } let dx: i32 = (toX as i64 - fromX as i64).abs() as i32;