mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 12:01:31 +11:00
refactor: wrap Menu.id
in Rc
This commit is contained in:
parent
89154aede0
commit
8d832c06f4
5
.changes/menu-rc.md
Normal file
5
.changes/menu-rc.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"muda": "patch"
|
||||
---
|
||||
|
||||
Wrapped the `id` field of the `Menu` struct in an `Rc` to be consistent with other menu structs and make it cheaper to clone.
|
|
@ -10,7 +10,7 @@ use crate::{util::AddOp, ContextMenu, IsMenuItem, MenuId, MenuItemKind, Position
|
|||
/// and used as the app global menu on macOS.
|
||||
#[derive(Clone)]
|
||||
pub struct Menu {
|
||||
id: MenuId,
|
||||
id: Rc<MenuId>,
|
||||
inner: Rc<RefCell<crate::platform_impl::Menu>>,
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ impl Menu {
|
|||
pub fn new() -> Self {
|
||||
let menu = crate::platform_impl::Menu::new(None);
|
||||
Self {
|
||||
id: menu.id().clone(),
|
||||
id: Rc::new(menu.id().clone()),
|
||||
inner: Rc::new(RefCell::new(menu)),
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl Menu {
|
|||
pub fn with_id<I: Into<MenuId>>(id: I) -> Self {
|
||||
let id = id.into();
|
||||
Self {
|
||||
id: id.clone(),
|
||||
id: Rc::new(id.clone()),
|
||||
inner: Rc::new(RefCell::new(crate::platform_impl::Menu::new(Some(id)))),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue