Fix clippy lints

master
Jonas Platte 2020-04-27 12:12:51 +02:00
parent 5cfac42101
commit 6d67cd2ac7
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 10 additions and 11 deletions

View File

@ -168,7 +168,7 @@ impl Client {
pub(crate) async fn calculate_room_names(&self) -> Vec<String> {
let mut res = Vec::new();
for (_id, room) in &self.joined_rooms {
for room in self.joined_rooms.values() {
let room = room.read().await;
res.push(room.room_name.calculate_name(&room.members))
}

View File

@ -166,8 +166,7 @@ impl RoomName {
.map(|mem| {
mem.display_name
.clone()
.unwrap_or(mem.user_id.localpart().to_string())
.to_string()
.unwrap_or_else(|| mem.user_id.localpart().to_string())
})
.collect::<Vec<String>>();
// stabilize ordering
@ -180,7 +179,7 @@ impl RoomName {
.map(|mem| {
mem.display_name
.clone()
.unwrap_or(mem.user_id.localpart().to_string())
.unwrap_or_else(|| mem.user_id.localpart().to_string())
})
.collect::<Vec<String>>();
names.sort();
@ -502,7 +501,7 @@ mod test {
.await;
assert_eq!(2, room.members.len());
for (_id, member) in &room.members {
for member in room.members.values() {
assert_eq!(MembershipState::Join, member.membership);
}

View File

@ -96,7 +96,7 @@ impl EventBuilder {
variant: fn(Ev) -> Event,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -112,7 +112,7 @@ impl EventBuilder {
variant: fn(Ev) -> Event,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -128,7 +128,7 @@ impl EventBuilder {
variant: fn(Ev) -> RoomEvent,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -144,7 +144,7 @@ impl EventBuilder {
variant: fn(Ev) -> StateEvent,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -156,7 +156,7 @@ impl EventBuilder {
/// Add a presence event to the presence events `Vec`.
pub fn add_presence_event_from_file<P: AsRef<Path>>(mut self, path: P) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<PresenceEvent>>(&val)
.unwrap()
.deserialize()
@ -174,7 +174,7 @@ impl EventBuilder {
P: AsRef<Path>,
{
let body = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let mock = Some(
mock(method, matcher)
.with_status(200)