From 1849b0ae08d9e58b4b0da6849fa642466e98bcb8 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 30 Dec 2022 17:42:06 +0100 Subject: [PATCH] desktop/global_shortcuts: Reformat & cleanup --- src/desktop/global_shortcuts.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/desktop/global_shortcuts.rs b/src/desktop/global_shortcuts.rs index 4ac5d8042..e5aaeb938 100644 --- a/src/desktop/global_shortcuts.rs +++ b/src/desktop/global_shortcuts.rs @@ -19,11 +19,13 @@ use crate::{ struct NewShortcutInfo { /// User-readable text describing what the shortcut does. description: String, - /// The preferred shortcut trigger, defined as described by the "shortcuts" XDG specification. Optional. + /// The preferred shortcut trigger, defined as described by the "shortcuts" + /// XDG specification. Optional. preferred_trigger: Option, } -/// Shortcut descriptor used to bind new shortcuts in [`GlobalShortcuts::bind_shortcuts`] +/// Shortcut descriptor used to bind new shortcuts in +/// [`GlobalShortcuts::bind_shortcuts`] #[derive(Clone, Serialize, Type, Debug)] pub struct NewShortcut(String, NewShortcutInfo); @@ -39,9 +41,11 @@ impl NewShortcut { ) } - /// Sets the preferred shortcut trigger, defined as described by the "shortcuts" XDG specification. - pub fn preferred_trigger(mut self, preferred_trigger: impl Into>) -> Self { - self.1.preferred_trigger = preferred_trigger.into(); + /// Sets the preferred shortcut trigger, defined as described by the + /// "shortcuts" XDG specification. + #[must_use] + pub fn preferred_trigger<'a>(mut self, preferred_trigger: impl Into>) -> Self { + self.1.preferred_trigger = preferred_trigger.into().map(ToOwned::to_owned); self } } @@ -51,13 +55,15 @@ impl NewShortcut { struct ShortcutInfo { /// User-readable text describing what the shortcut does. description: String, - /// User-readable text describing how to trigger the shortcut for the client to render. + /// User-readable text describing how to trigger the shortcut for the client + /// to render. trigger_description: String, } /// Struct that contains information about existing binded shortcut. /// -/// If you need to create a new shortcuts, take a look at [`NewShortcut`] instead. +/// If you need to create a new shortcuts, take a look at [`NewShortcut`] +/// instead. #[derive(Clone, Deserialize, Type, Debug)] pub struct Shortcut(String, ShortcutInfo); @@ -72,7 +78,8 @@ impl Shortcut { &self.1.description } - /// User-readable text describing how to trigger the shortcut for the client to render. + /// User-readable text describing how to trigger the shortcut for the client + /// to render. pub fn trigger_description(&self) -> &str { &self.1.trigger_description } @@ -169,7 +176,8 @@ impl Deactivated { } } -/// Indicates that the information associated with some of the shortcuts has changed. +/// Indicates that the information associated with some of the shortcuts has +/// changed. #[derive(Debug, Deserialize, Type)] pub struct ShortcutsChanged(OwnedObjectPath, Vec); @@ -293,7 +301,8 @@ impl<'a> GlobalShortcuts<'a> { receive_signal(self.inner(), "Deactivated").await } - /// Signal emitted when information associated with some of the shortcuts has changed. + /// Signal emitted when information associated with some of the shortcuts + /// has changed. /// /// # Specifications ///