From d239c32c45d10655f3a37753a83af0a96a33332b Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 6 Nov 2021 23:08:44 +0000 Subject: [PATCH] Simplified a few comparisons in Rust code. --- rust/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 2d1f410..cfea4eb 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -205,7 +205,7 @@ impl QrCode { /// long to fit in any version in the given range at the given ECC level. pub fn encode_segments_advanced(segs: &[QrSegment], mut ecl: QrCodeEcc, minversion: Version, maxversion: Version, mask: Option, boostecl: bool) -> Result { - assert!(minversion.value() <= maxversion.value(), "Invalid value"); + assert!(minversion <= maxversion, "Invalid value"); // Find the minimal version number to use let mut version: Version = minversion; @@ -214,7 +214,7 @@ impl QrCode { let dataused: Option = QrSegment::get_total_bits(segs, version); if dataused.map_or(false, |n| n <= datacapacitybits) { break dataused.unwrap(); // This version number is found to be suitable - } else if version.value() >= maxversion.value() { // All versions in the range could not fit the given data + } else if version >= maxversion { // All versions in the range could not fit the given data let msg: String = match dataused { None => String::from("Segment too long"), Some(n) => format!("Data length = {} bits, Max capacity = {} bits",