From 2c688fd40f3df227eed4925b675ebe8f0dab1bb5 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 5 Feb 2024 15:13:08 +0100 Subject: [PATCH] chore(ui): Remove the `get_` prefix of an internal filter type. This patch renames `NonLeftRoomMatcher::get_state` to `::state`. This is more Rust idiomatic. --- .../src/room_list_service/filters/non_left.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs index 4a7a5f04f..b31750772 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs @@ -7,7 +7,7 @@ struct NonLeftRoomMatcher where F: Fn(&RoomListEntry) -> Option, { - get_state: F, + state: F, } impl NonLeftRoomMatcher @@ -19,7 +19,7 @@ where return false; } - if let Some(state) = (self.get_state)(room) { + if let Some(state) = (self.state)(room) { state != RoomState::Left } else { false @@ -33,7 +33,7 @@ pub fn new_filter(client: &Client) -> impl Filter { let client = client.clone(); let matcher = NonLeftRoomMatcher { - get_state: move |room| { + state: move |room| { let room_id = room.as_room_id()?; let room = client.get_room(room_id)?; Some(room.state()) @@ -54,19 +54,19 @@ mod tests { #[test] fn test_all_non_left_kind_of_room_list_entry() { // When we can't figure out the room state, nothing matches. - let matcher = NonLeftRoomMatcher { get_state: |_| None }; + let matcher = NonLeftRoomMatcher { state: |_| None }; assert!(!matcher.matches(&RoomListEntry::Empty)); assert!(!matcher.matches(&RoomListEntry::Filled(room_id!("!r0:bar.org").to_owned()))); assert!(!matcher.matches(&RoomListEntry::Invalidated(room_id!("!r0:bar.org").to_owned()))); // When a room has been left, it doesn't match. - let matcher = NonLeftRoomMatcher { get_state: |_| Some(RoomState::Left) }; + let matcher = NonLeftRoomMatcher { state: |_| Some(RoomState::Left) }; assert!(!matcher.matches(&RoomListEntry::Empty)); assert!(!matcher.matches(&RoomListEntry::Filled(room_id!("!r0:bar.org").to_owned()))); assert!(!matcher.matches(&RoomListEntry::Invalidated(room_id!("!r0:bar.org").to_owned()))); // When a room has been joined, it does match (unless it's empty). - let matcher = NonLeftRoomMatcher { get_state: |_| Some(RoomState::Joined) }; + let matcher = NonLeftRoomMatcher { state: |_| Some(RoomState::Joined) }; assert!(!matcher.matches(&RoomListEntry::Empty)); assert!(matcher.matches(&RoomListEntry::Filled(room_id!("!r0:bar.org").to_owned()))); assert!(matcher.matches(&RoomListEntry::Invalidated(room_id!("!r0:bar.org").to_owned())));