[fractal] fractal-matrix-api: Drop redundant closures
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-matrix-api: Drop redundant closures
- Date: Sun, 23 Dec 2018 11:06:44 +0000 (UTC)
commit 4d34eed4aba1d9da662f5ce05614dec57feaab45
Author: Zeeshan Ali <zeenix collabora co uk>
Date: Mon Dec 10 17:15:41 2018 +0100
fractal-matrix-api: Drop redundant closures
Fixing clippy error:
```
error: redundant closure found
--> fractal-matrix-api/src/util.rs:219:60
|
219 | r.prev_batch = timeline["prev_batch"].as_str().map(|s| String::from(s));
| ^^^^^^^^^^^^^^^^^^^ help: remove closure
as shown: `String::from`
|
= note: `-D clippy::redundant-closure` implied by `-D warnings`
= help: for further information visit
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_closure
```
Related: #370
fractal-matrix-api/src/backend/room.rs | 2 +-
fractal-matrix-api/src/model/message.rs | 4 ++--
fractal-matrix-api/src/util.rs | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs
index c3c0af8..911e2b0 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-matrix-api/src/backend/room.rs
@@ -140,7 +140,7 @@ pub fn get_room_messages(bk: &Backend, roomid: String, from: String) -> Result<(
let array = r["chunk"].as_array();
let evs = array.unwrap().iter().rev();
let list = Message::from_json_events_iter(roomid.clone(), evs);
- let prev_batch = r["end"].as_str().map(|s| String::from(s));
+ let prev_batch = r["end"].as_str().map(String::from);
tx.send(BKResponse::RoomMessagesTo(list, roomid, prev_batch))
.unwrap();
},
diff --git a/fractal-matrix-api/src/model/message.rs b/fractal-matrix-api/src/model/message.rs
index d50c735..2a7bc94 100644
--- a/fractal-matrix-api/src/model/message.rs
+++ b/fractal-matrix-api/src/model/message.rs
@@ -152,8 +152,8 @@ impl Message {
fn parse_m_room_message(msg: &mut Message, c: &JsonValue) {
let mtype = c["msgtype"].as_str().unwrap_or("");
let body = c["body"].as_str().unwrap_or("");
- let formatted_body = c["formatted_body"].as_str().map(|s| String::from(s));
- let format = c["format"].as_str().map(|s| String::from(s));
+ let formatted_body = c["formatted_body"].as_str().map(String::from);
+ let format = c["format"].as_str().map(String::from);
match mtype {
"m.image" | "m.file" | "m.video" | "m.audio" => {
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index 07cffed..42b270a 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -216,7 +216,7 @@ pub fn get_rooms_from_json(r: &JsonValue, userid: &str, baseu: &Url) -> Result<V
.as_i64()
.unwrap_or(0) as i32;
- r.prev_batch = timeline["prev_batch"].as_str().map(|s| String::from(s));
+ r.prev_batch = timeline["prev_batch"].as_str().map(String::from);
if let Some(ev) = dataevs.as_array() {
for tag in ev.iter().filter(|x| x["type"] == "m.tag") {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]