From a2f49a74d08a0cff2e892932b484a88a4034f627 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 19 Jul 2021 21:01:24 +0700 Subject: Replace `content` with `title` in `menu` module --- core/src/menu.rs | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'core') diff --git a/core/src/menu.rs b/core/src/menu.rs index e9d3d13a..3ad7b7a2 100644 --- a/core/src/menu.rs +++ b/core/src/menu.rs @@ -59,7 +59,7 @@ pub enum Entry { /// Item for a [`Menu`] Item { /// The title of the item - content: String, + title: String, /// The [`Hotkey`] to activate the item, if any hotkey: Option, /// The message generated when the item is activated @@ -68,7 +68,7 @@ pub enum Entry { /// Dropdown for a [`Menu`] Dropdown { /// Title of the dropdown - content: String, + title: String, /// The submenu of the dropdown submenu: Menu, }, @@ -79,43 +79,40 @@ pub enum Entry { impl Entry { /// Creates an [`Entry::Item`]. pub fn item>( - content: S, + title: S, hotkey: impl Into>, on_activation: Message, ) -> Self { - let content = content.into(); + let title = title.into(); let hotkey = hotkey.into(); Self::Item { - content, + title, hotkey, on_activation, } } /// Creates an [`Entry::Dropdown`]. - pub fn dropdown>( - content: S, - submenu: Menu, - ) -> Self { - let content = content.into(); + pub fn dropdown>(title: S, submenu: Menu) -> Self { + let title = title.into(); - Self::Dropdown { content, submenu } + Self::Dropdown { title, submenu } } fn map(self, f: &impl Fn(Message) -> B) -> Entry { match self { Self::Item { - content, + title, hotkey, on_activation, } => Entry::Item { - content, + title, hotkey, on_activation: f(on_activation), }, - Self::Dropdown { content, submenu } => Entry::Dropdown { - content, + Self::Dropdown { title, submenu } => Entry::Dropdown { + title, submenu: submenu.map(f), }, Self::Separator => Entry::Separator, @@ -127,22 +124,20 @@ impl PartialEq for Entry { fn eq(&self, other: &Self) -> bool { match (self, other) { ( + Entry::Item { title, hotkey, .. }, Entry::Item { - content, hotkey, .. - }, - Entry::Item { - content: other_content, + title: other_title, hotkey: other_hotkey, .. }, - ) => content == other_content && hotkey == other_hotkey, + ) => title == other_title && hotkey == other_hotkey, ( - Entry::Dropdown { content, submenu }, + Entry::Dropdown { title, submenu }, Entry::Dropdown { - content: other_content, + title: other_title, submenu: other_submenu, }, - ) => content == other_content && submenu == other_submenu, + ) => title == other_title && submenu == other_submenu, (Entry::Separator, Entry::Separator) => true, _ => false, } -- cgit