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
This commit is contained in:
Zeeshan Ali 2018-12-10 17:15:41 +01:00 committed by Alexandre Franke
parent 903ee29aea
commit d3d5f91cd8
2 changed files with 6 additions and 4 deletions

View file

@ -575,7 +575,9 @@ pub fn direct_chat(bk: &Backend, user: Member, internal_id: String) -> Result<()
let directs = &mut data.lock().unwrap().m_direct; let directs = &mut data.lock().unwrap().m_direct;
if directs.contains_key(&m.uid) { 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 { } else {
directs.insert(m.uid.clone(), vec![id.clone()]); directs.insert(m.uid.clone(), vec![id.clone()]);
} }

View file

@ -241,9 +241,9 @@ pub fn get_rooms_from_json(r: &JsonValue, userid: &str, baseu: &Url) -> Result<V
// Adding fully read to the receipts events // Adding fully read to the receipts events
if let Some(evs) = dataevs.as_array() { if let Some(evs) = dataevs.as_array() {
if let Some(fread) = evs.into_iter().find(|x| x["type"] == "m.fully_read") { if let Some(fread) = evs.into_iter().find(|x| x["type"] == "m.fully_read") {
fread["content"]["event_id"] if let Some(ev) = fread["content"]["event_id"].as_str() {
.as_str() r.add_receipt_from_fully_read(userid, ev);
.map(|ev| r.add_receipt_from_fully_read(userid, ev)); }
} }
} }