diff --git a/crates/ui2/src/components/disclosure.rs b/crates/ui2/src/components/disclosure.rs index 22cad27f58..7d9a69bb3a 100644 --- a/crates/ui2/src/components/disclosure.rs +++ b/crates/ui2/src/components/disclosure.rs @@ -1,14 +1,10 @@ -use std::rc::Rc; - +use crate::{prelude::*, Color, Icon, IconButton, IconSize}; use gpui::ClickEvent; -use crate::prelude::*; -use crate::{Color, Icon, IconButton, IconSize}; - #[derive(IntoElement)] pub struct Disclosure { is_open: bool, - on_toggle: Option>, + on_toggle: Option>, } impl Disclosure { @@ -21,7 +17,7 @@ impl Disclosure { pub fn on_toggle( mut self, - handler: impl Into>>, + handler: impl Into>>, ) -> Self { self.on_toggle = handler.into(); self diff --git a/crates/ui2/src/components/list/list_header.rs b/crates/ui2/src/components/list/list_header.rs index 799b1c5dae..933a1a95d7 100644 --- a/crates/ui2/src/components/list/list_header.rs +++ b/crates/ui2/src/components/list/list_header.rs @@ -1,18 +1,14 @@ -use std::rc::Rc; - +use crate::{h_stack, prelude::*, Disclosure, Icon, IconElement, IconSize, Label}; use gpui::{AnyElement, ClickEvent, Div}; use smallvec::SmallVec; -use crate::prelude::*; -use crate::{h_stack, Disclosure, Icon, IconElement, IconSize, Label}; - #[derive(IntoElement)] pub struct ListHeader { label: SharedString, left_icon: Option, meta: SmallVec<[AnyElement; 2]>, toggle: Option, - on_toggle: Option>, + on_toggle: Option>, inset: bool, selected: bool, } @@ -39,7 +35,7 @@ impl ListHeader { mut self, on_toggle: impl Fn(&ClickEvent, &mut WindowContext) + 'static, ) -> Self { - self.on_toggle = Some(Rc::new(on_toggle)); + self.on_toggle = Some(Box::new(on_toggle)); self } diff --git a/crates/ui2/src/components/list/list_item.rs b/crates/ui2/src/components/list/list_item.rs index 529f2c2a58..9db70c2ed2 100644 --- a/crates/ui2/src/components/list/list_item.rs +++ b/crates/ui2/src/components/list/list_item.rs @@ -1,14 +1,10 @@ -use std::rc::Rc; - +use crate::{prelude::*, Avatar, Disclosure, Icon, IconElement, IconSize}; use gpui::{ px, AnyElement, AnyView, ClickEvent, Div, ImageSource, MouseButton, MouseDownEvent, Pixels, Stateful, }; use smallvec::SmallVec; -use crate::prelude::*; -use crate::{Avatar, Disclosure, Icon, IconElement, IconSize}; - #[derive(IntoElement)] pub struct ListItem { id: ElementId, @@ -20,10 +16,10 @@ pub struct ListItem { left_slot: Option, toggle: Option, inset: bool, - on_click: Option>, - on_toggle: Option>, + on_click: Option>, + on_toggle: Option>, tooltip: Option AnyView + 'static>>, - on_secondary_mouse_down: Option>, + on_secondary_mouse_down: Option>, children: SmallVec<[AnyElement; 2]>, } @@ -46,7 +42,7 @@ impl ListItem { } pub fn on_click(mut self, handler: impl Fn(&ClickEvent, &mut WindowContext) + 'static) -> Self { - self.on_click = Some(Rc::new(handler)); + self.on_click = Some(Box::new(handler)); self } @@ -54,7 +50,7 @@ impl ListItem { mut self, handler: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static, ) -> Self { - self.on_secondary_mouse_down = Some(Rc::new(handler)); + self.on_secondary_mouse_down = Some(Box::new(handler)); self } @@ -87,7 +83,7 @@ impl ListItem { mut self, on_toggle: impl Fn(&ClickEvent, &mut WindowContext) + 'static, ) -> Self { - self.on_toggle = Some(Rc::new(on_toggle)); + self.on_toggle = Some(Box::new(on_toggle)); self }