From 3185c310e35dbe8100a5724d9bad8019aebc67d6 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Thu, 9 Sep 2021 18:08:14 +0000 Subject: [PATCH] Refactored a repeated expression in Rust code. --- rust/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 4b7715a..b8e16e7 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1035,13 +1035,17 @@ impl QrSegment { pub fn make_segments(text: &[char]) -> Vec { if text.is_empty() { vec![] - } else if QrSegment::is_numeric(text) { - vec![QrSegment::make_numeric(text)] - } else if QrSegment::is_alphanumeric(text) { - vec![QrSegment::make_alphanumeric(text)] } else { - let s: String = text.iter().cloned().collect(); - vec![QrSegment::make_bytes(s.as_bytes())] + vec![ + if QrSegment::is_numeric(text) { + QrSegment::make_numeric(text) + } else if QrSegment::is_alphanumeric(text) { + QrSegment::make_alphanumeric(text) + } else { + let s: String = text.iter().cloned().collect(); + QrSegment::make_bytes(s.as_bytes()) + } + ] } }