diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-01-02 21:10:55 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-01-02 21:10:55 +0100 |
commit | 16a56f12cd2e66e10f8bb5e2c4026d3a7148e680 (patch) | |
tree | 913bd32a563b32302c2e14304460a3cbc9a88a39 /examples/zot/channel_stream.rs | |
parent | 7f306445cb78d52f598eca1810dc2c5002e34a4a (diff) | |
download | rust-zotapi-16a56f12cd2e66e10f8bb5e2c4026d3a7148e680.tar.gz rust-zotapi-16a56f12cd2e66e10f8bb5e2c4026d3a7148e680.tar.bz2 rust-zotapi-16a56f12cd2e66e10f8bb5e2c4026d3a7148e680.zip |
Cargo fmt
Diffstat (limited to 'examples/zot/channel_stream.rs')
-rw-r--r-- | examples/zot/channel_stream.rs | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/examples/zot/channel_stream.rs b/examples/zot/channel_stream.rs index a278244..b50f93f 100644 --- a/examples/zot/channel_stream.rs +++ b/examples/zot/channel_stream.rs @@ -25,11 +25,10 @@ pub fn fetch(client: &zotapi::Client, raw: bool) { Ok(payload) => { if raw { println!("{}", payload); - } - else { + } else { list(&payload); } - }, + } Err(e) => { println!("Error getting channel stream: {:?}", e); } @@ -43,10 +42,8 @@ fn list(payload: &str) { print_item(&item); println!("-----"); } - }, - Ok(_) => { - println!("Wrong type returned, expected an array.") - }, + } + Ok(_) => println!("Wrong type returned, expected an array."), Err(e) => { println!("Error: {}", e); } @@ -76,8 +73,9 @@ fn get_object_type(item: &serde_json::Value) -> &str { fn get_tags(item: &serde_json::Value) -> String { match item["tags"] { - serde_json::Value::Array(ref v) => { - v.iter().map(|t| { + serde_json::Value::Array(ref v) => v + .iter() + .map(|t| { let prefix = match get_str(&t["type"]) { "hashtag" => "#", "forum" => "!", @@ -85,14 +83,11 @@ fn get_tags(item: &serde_json::Value) -> String { _ => "", }; format!("{}{}", prefix, get_str(&t["tag"])) - }).collect::<Vec<_>>().join(", ") - }, - serde_json::Value::Null => { - String::new() - }, - _ => { - String::from("invalid tags, expected array...") - } + }) + .collect::<Vec<_>>() + .join(", "), + serde_json::Value::Null => String::new(), + _ => String::from("invalid tags, expected array..."), } } |