From 04201de443f559252563647abf4b4e1901cb08ae Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 8 Apr 2022 13:13:32 -0400 Subject: [PATCH] simplify text.json loading code --- src/math_app.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/math_app.rs b/src/math_app.rs index a642153..00858cd 100644 --- a/src/math_app.rs +++ b/src/math_app.rs @@ -108,17 +108,8 @@ lazy_static::lazy_static! { panic!("Font File {} not expected!", path_string); } } - } else if path_string.ends_with(".json") { - // Parse json file - let string_data = str::from_utf8(&data).unwrap().to_string(); - match path_string.as_ref() { - "text.json" => { - text_data = Some(SerdeValueHelper::new(&string_data).parse_values()); - }, - _ => { - panic!("Json file {} not expected!", path_string); - } - } + } else if path_string == "text.json" { + text_data = Some(SerdeValueHelper::new(str::from_utf8(&data).expect("unable to read text.json")).parse_values()); } else { panic!("Other file {} not expected!", path_string); }