if let instead of match single
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -28,10 +28,12 @@ fn main() {
|
|||||||
let json = json::parse(s).unwrap();
|
let json = json::parse(s).unwrap();
|
||||||
|
|
||||||
// TODO I think there is a better alternative syntax to match here.
|
// TODO I think there is a better alternative syntax to match here.
|
||||||
let json_outputs = match json {
|
let json_outputs =
|
||||||
JsonValue::Array(vec) => vec,
|
if let JsonValue::Array(vec) = json {
|
||||||
_ => panic!("json was not an array")
|
vec
|
||||||
};
|
} else {
|
||||||
|
panic!("json is not an array");
|
||||||
|
};
|
||||||
|
|
||||||
let size = json_outputs.len();
|
let size = json_outputs.len();
|
||||||
if size == 1 {
|
if size == 1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user