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
This commit is contained in:
parent
7152795796
commit
5295964b6a
1 changed files with 4 additions and 6 deletions
|
@ -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 || {
|
||||
|
|
Loading…
Reference in a new issue