From d3d5f91cd856aac283a20e7cabf160a1f54807bb Mon Sep 17 00:00:00 2001 From: Zeeshan Ali Date: Mon, 10 Dec 2018 17:15:41 +0100 Subject: [PATCH] fractal-matrix-api: Drop unit closure Fixing clippy error: ``` error: called `map(f)` on an Option value where `f` is a unit closure --> fractal-matrix-api/src/util.rs:248:17 | 248 | / fread["content"]["event_id"] 249 | | .as_str() 250 | | .map(|ev| r.add_receipt_from_fully_read(userid, ev)); | |________________________________________________________________________^ | = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/master/index.html#option_map_unit_fn help: try this | 248 | if let Some(ev) = fread["content"]["event_id"] 249 | .as_str() { r.add_receipt_from_fully_read(userid, ev) } | ``` Related: #370 --- fractal-matrix-api/src/backend/room.rs | 4 +++- fractal-matrix-api/src/util.rs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs index 4d7e139f..552c3846 100644 --- a/fractal-matrix-api/src/backend/room.rs +++ b/fractal-matrix-api/src/backend/room.rs @@ -575,7 +575,9 @@ pub fn direct_chat(bk: &Backend, user: Member, internal_id: String) -> Result<() let directs = &mut data.lock().unwrap().m_direct; if directs.contains_key(&m.uid) { - directs.get_mut(&m.uid).map(|v| v.push(id.clone())); + if let Some(v) = directs.get_mut(&m.uid) { + v.push(id.clone()) + }; } else { directs.insert(m.uid.clone(), vec![id.clone()]); } diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs index ec4b6198..b97d6029 100644 --- a/fractal-matrix-api/src/util.rs +++ b/fractal-matrix-api/src/util.rs @@ -241,9 +241,9 @@ pub fn get_rooms_from_json(r: &JsonValue, userid: &str, baseu: &Url) -> Result