[fractal] fractal-matrix-api: Don't loop for unwrapping Option
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-matrix-api: Don't loop for unwrapping Option
- Date: Sun, 23 Dec 2018 11:06:34 +0000 (UTC)
commit bdadb58c527506fa8c0be856e3e2578ecda7abd2
Author: Zeeshan Ali <zeenix collabora co uk>
Date: Mon Dec 10 17:15:41 2018 +0100
fractal-matrix-api: Don't loop for unwrapping Option
Fixing clippy error:
```
error: for loop over `dataevs.as_array()`, which is an `Option`. This is more readably written as an `if
let` statement.
--> fractal-matrix-api/src/util.rs:221:19
|
221 | for ev in dataevs.as_array() {
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::for_loop_over_option)] on by default
= help: consider replacing `for ev in dataevs.as_array()` with `if let Some(ev) = dataevs.as_array()`
= help: for further information visit
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#for_loop_over_option
```
Related: #370
fractal-matrix-api/src/util.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index eb3f406..07cffed 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -218,7 +218,7 @@ pub fn get_rooms_from_json(r: &JsonValue, userid: &str, baseu: &Url) -> Result<V
r.prev_batch = timeline["prev_batch"].as_str().map(|s| String::from(s));
- for ev in dataevs.as_array() {
+ if let Some(ev) = dataevs.as_array() {
for tag in ev.iter().filter(|x| x["type"] == "m.tag") {
if let Some(_) = tag["content"]["tags"]["m.favourite"].as_object() {
r.fav = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]