use crate::{ adapter::AdapterElement, element::{AnyElement, Element}, }; use gpui::ViewContext; pub fn view(mut render: F) -> ViewFn where F: 'static + FnMut(&mut ViewContext) -> E, E: Element, { ViewFn(Box::new(move |cx| (render)(cx).into_any())) } pub struct ViewFn(Box) -> AnyElement>); impl gpui::Entity for ViewFn { type Event = (); } impl gpui::View for ViewFn { fn render(&mut self, cx: &mut ViewContext) -> gpui::AnyElement { use gpui::Element as _; AdapterElement((self.0)(cx)).into_any() } }