From 87859ed835ab29d71d75932d9f32f6121be293d9 Mon Sep 17 00:00:00 2001 From: stephen Date: Wed, 23 Aug 2023 13:08:11 +0000 Subject: [PATCH] if let instead of match single --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7b5a523..c3bcaa9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,10 +28,12 @@ fn main() { let json = json::parse(s).unwrap(); // TODO I think there is a better alternative syntax to match here. - let json_outputs = match json { - JsonValue::Array(vec) => vec, - _ => panic!("json was not an array") - }; + let json_outputs = + if let JsonValue::Array(vec) = json { + vec + } else { + panic!("json is not an array"); + }; let size = json_outputs.len(); if size == 1 {