diff --git a/client/src/room/event.rs b/client/src/room/event.rs index c9f09eb..6feb1f9 100644 --- a/client/src/room/event.rs +++ b/client/src/room/event.rs @@ -327,11 +327,6 @@ mod tests { assert_eq!(request, ServerRequest::RoomListRequest); } - // Cannot get the compiler to be satisfied when borrowing the name... - fn room_name(pair: &(String, RoomState)) -> String { - pair.0.clone() - } - #[test] fn handle_list_request_sends_immediate_response() { let mut options = ContextOptions::default(); @@ -360,7 +355,12 @@ mod tests { _ => panic!("Unexpected control response: {:?}", response), }; - rooms.sort_by_key(room_name); + // `sort_by_key()` cannot handle an extractor function that returns + // references, so we use `sort_by()` instead. + // See: https://github.com/rust-lang/rust/issues/34162 + rooms.sort_unstable_by(|(ref lhs_name, _), (ref rhs_name, _)| { + lhs_name.cmp(rhs_name) + }); assert_eq!( rooms,