mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 12:01:31 +11:00
feat: add MenuItemKind::id
(#113)
This commit is contained in:
parent
9c4d6bb14e
commit
bce7540bba
5
.changes/menu-item-kind-id.md
Normal file
5
.changes/menu-item-kind-id.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"muda": "patch"
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `MenuItemKind::id` convenient method to get access to the inner kind id.
|
12
src/lib.rs
12
src/lib.rs
|
@ -166,6 +166,17 @@ pub enum MenuItemKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuItemKind {
|
impl MenuItemKind {
|
||||||
|
/// Returns the id associated with this menu item.
|
||||||
|
pub fn id(&self) -> &MenuId {
|
||||||
|
match self {
|
||||||
|
MenuItemKind::MenuItem(i) => i.id(),
|
||||||
|
MenuItemKind::Submenu(i) => i.id(),
|
||||||
|
MenuItemKind::Predefined(i) => i.id(),
|
||||||
|
MenuItemKind::Check(i) => i.id(),
|
||||||
|
MenuItemKind::Icon(i) => i.id(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Casts this item to a [`MenuItem`], and returns `None` if it wasn't.
|
/// Casts this item to a [`MenuItem`], and returns `None` if it wasn't.
|
||||||
pub fn as_menuitem(&self) -> Option<&MenuItem> {
|
pub fn as_menuitem(&self) -> Option<&MenuItem> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -267,6 +278,7 @@ pub(crate) enum MenuItemType {
|
||||||
Check,
|
Check,
|
||||||
Icon,
|
Icon,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MenuItemType {
|
impl Default for MenuItemType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::MenuItem
|
Self::MenuItem
|
||||||
|
|
Loading…
Reference in a new issue