[fractal] fractal-matrix-api: Drop redundant pattern matching



commit ae52f0e5bb4eaba9e4b9e667a0887923d17ad21b
Author: Zeeshan Ali <zeenix collabora co uk>
Date:   Mon Dec 10 17:15:41 2018 +0100

    fractal-matrix-api: Drop redundant pattern matching
    
    Fixing clippy error:
    
    ```
    error: redundant pattern matching, consider using `is_some()`
       --> fractal-matrix-api/src/util.rs:223:24
        |
    223 |                   if let Some(_) = tag["content"]["tags"]["m.favourite"].as_object() {
        |  _________________-      ^^^^^^^
    224 | |                     r.fav = true;
    225 | |                 }
        | |_________________- help: try this: `if tag["content"]["tags"]["m.favourite"].as_object().is_some()`
        |
        = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
        = help: for further information visit 
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_pattern_matching
    
    ```
    
    Related: #370

 fractal-matrix-api/src/backend/room.rs | 2 +-
 fractal-matrix-api/src/util.rs         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs
index 911e2b0..4d7e139 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-matrix-api/src/backend/room.rs
@@ -194,7 +194,7 @@ fn parse_context(
             let mut ms: Vec<Message> = vec![];
             let array = r["events_before"].as_array();
             for msg in array.unwrap().iter().rev() {
-                if let None = id {
+                if id.is_none() {
                     id = Some(msg["event_id"].as_str().unwrap_or("").to_string());
                 }
 
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index 42b270a..9f079d1 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -220,7 +220,7 @@ pub fn get_rooms_from_json(r: &JsonValue, userid: &str, baseu: &Url) -> Result<V
 
         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() {
+                if tag["content"]["tags"]["m.favourite"].as_object().is_some() {
                     r.fav = true;
                 }
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]