Skip to content

Commit 3b48517

Browse files
committed
cleanup unnecessary cast_ref usage for an action enum that impls Copy
1 parent a631d14 commit 3b48517

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/home/room_screen.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,13 +1131,11 @@ impl Widget for RoomScreen {
11311131
return false;
11321132
}
11331133

1134-
match action
1135-
.as_widget_action()
1136-
.cast_ref::<RoomInputPopupMenuAction>()
1137-
{
1134+
// Handle actions related to the room input popup menu.
1135+
match action.as_widget_action().cast() {
11381136
RoomInputPopupMenuAction::None => {}
1139-
menu_action => {
1140-
self.handle_room_input_popup_menu_action(cx, *menu_action);
1137+
room_popup_menu_action => {
1138+
self.handle_room_input_popup_menu_action(cx, room_popup_menu_action);
11411139
return false;
11421140
}
11431141
}

src/shared/room_input_popup_menu.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,22 @@ script_mod! {
8686
}
8787
}
8888

89+
/// Widget actions related to the room input popup menu.
8990
#[derive(Clone, Copy, Debug, Default, PartialEq)]
9091
pub enum RoomInputPopupMenuAction {
92+
/// Emitted by the RoomInputBar when the add button is clicked,
93+
/// which is a request to show the room input popup menu.
9194
Show { button_rect: Rect },
95+
/// Emitted by the RoomInputPopupMenu when the upload photo/video button is clicked.
9296
UploadPhotoOrVideo,
97+
/// Emitted by the RoomInputPopupMenu when the upload file button is clicked.
9398
UploadFile,
99+
/// Emitted by the RoomInputPopupMenu when the send location button is clicked.
94100
SendCurrentLocation,
95101
#[default]
96102
None,
97103
}
98104

99-
impl ActionDefaultRef for RoomInputPopupMenuAction {
100-
fn default_ref() -> &'static Self {
101-
static DEFAULT: RoomInputPopupMenuAction = RoomInputPopupMenuAction::None;
102-
&DEFAULT
103-
}
104-
}
105-
106105
#[derive(Script, ScriptHook, Widget)]
107106
pub struct RoomInputPopupMenu {
108107
#[source] source: ScriptObjectRef,
@@ -226,9 +225,9 @@ impl RoomInputPopupMenuRef {
226225
}
227226

228227
pub fn selected(&self, actions: &Actions) -> Option<RoomInputPopupMenuAction> {
229-
match actions.find_widget_action(self.widget_uid()).cast_ref() {
228+
match actions.find_widget_action(self.widget_uid()).cast() {
230229
RoomInputPopupMenuAction::None => None,
231-
action => Some(*action),
230+
action => Some(action),
232231
}
233232
}
234233

0 commit comments

Comments
 (0)