refactor(clippy): impl as_ref on wm struct

This commit is contained in:
LGUG2Z
2022-02-05 13:59:02 -08:00
parent 02c54734fb
commit cd894655db
3 changed files with 8 additions and 2 deletions

View File

@@ -675,7 +675,7 @@ impl WindowManager {
self.process_command(message.clone())?; self.process_command(message.clone())?;
notify_subscribers(&serde_json::to_string(&Notification { notify_subscribers(&serde_json::to_string(&Notification {
event: NotificationEvent::Socket(message.clone()), event: NotificationEvent::Socket(message.clone()),
state: (&*self).into(), state: self.as_ref().into(),
})?)?; })?)?;
} }

View File

@@ -478,7 +478,7 @@ impl WindowManager {
serde_json::to_writer_pretty(&file, &known_hwnds)?; serde_json::to_writer_pretty(&file, &known_hwnds)?;
notify_subscribers(&serde_json::to_string(&Notification { notify_subscribers(&serde_json::to_string(&Notification {
event: NotificationEvent::WindowManager(*event), event: NotificationEvent::WindowManager(*event),
state: (&*self).into(), state: self.as_ref().into(),
})?)?; })?)?;
tracing::info!("processed: {}", event.window().to_string()); tracing::info!("processed: {}", event.window().to_string());

View File

@@ -81,6 +81,12 @@ pub struct State {
pub border_overflow_identifiers: Vec<String>, pub border_overflow_identifiers: Vec<String>,
} }
impl AsRef<Self> for WindowManager {
fn as_ref(&self) -> &Self {
self
}
}
impl From<&WindowManager> for State { impl From<&WindowManager> for State {
fn from(wm: &WindowManager) -> Self { fn from(wm: &WindowManager) -> Self {
Self { Self {