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;