if let instead of match single
This commit is contained in:
@@ -28,9 +28,11 @@ 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();
|
||||
|
||||
Reference in New Issue
Block a user