[fractal] fractal-matrix-api: Don't call a function in Result::unwrap() arg
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-matrix-api: Don't call a function in Result::unwrap() arg
- Date: Sun, 23 Dec 2018 11:07:25 +0000 (UTC)
commit 5295964b6a7d936e9ed65f68f1e6b5d369fa2c94
Author: Zeeshan Ali <zeenix collabora co uk>
Date: Wed Dec 12 23:05:44 2018 +0100
fractal-matrix-api: Don't call a function in Result::unwrap() arg
This fixes this errors from clippy:
```
warning: use of `unwrap_or` followed by a call to `new`
--> fractal-matrix-api/src/backend/room.rs:80:30
|
80 | avatar = util::get_room_avatar(&baseu, &tk, &userid, &roomid)
| ______________________________^
81 | | .unwrap_or(String::from(""));
| |_________________________________________________^ help: try this: `util::get_room_avatar(&baseu,
&tk, &userid, &roomid).unwrap_or_default()`
|
= note: #[warn(clippy::or_fun_call)] on by default
= help: for further information visit
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#or_fun_call
```
Related: #370
fractal-matrix-api/src/backend/room.rs | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs
index 09f8898..2f33384 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-matrix-api/src/backend/room.rs
@@ -74,16 +74,14 @@ pub fn get_room_avatar(bk: &Backend, roomid: String) -> Result<(), Error> {
String::from("")
}
}
- None => {
- util::get_room_avatar(&baseu, &tk, &userid, &roomid).unwrap_or(String::from(""))
- }
+ None => util::get_room_avatar(&baseu, &tk, &userid, &roomid).unwrap_or_default(),
};
tx.send(BKResponse::RoomAvatar(roomid, avatar)).unwrap();
},
|err: Error| match err {
Error::MatrixError(ref js) if js["errcode"].as_str().unwrap_or("") == "M_NOT_FOUND" => {
- let avatar = util::get_room_avatar(&baseu, &tk, &userid, &roomid)
- .unwrap_or(String::from(""));
+ let avatar =
+ util::get_room_avatar(&baseu, &tk, &userid, &roomid).unwrap_or_default();
tx.send(BKResponse::RoomAvatar(roomid, avatar)).unwrap();
}
_ => {
@@ -155,7 +153,7 @@ pub fn get_room_messages_from_msg(bk: &Backend, roomid: String, msg: Message) ->
// normal get_room_messages
let baseu = bk.get_base_url()?;
let tk = bk.data.lock().unwrap().access_token.clone();
- let id = msg.id.unwrap_or("".to_string());
+ let id = msg.id.unwrap_or_default();
let tx = bk.internal_tx.clone();
thread::spawn(move || {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]