Skip to main content

builderx_gpui/
lib.rs

1//! gpui adapter implementations for builderx.
2//!
3//! Plug this adapter in (feature `gpui` on the `builderx` facade) to make the
4//! `bx!` macro emit gpui-compatible builder chains.
5
6use builderx_core::{BxAdapter, CanAttach, CanAttachMany};
7
8/// Adapter type for gpui builders.
9pub struct GpuiAdapter;
10
11impl BxAdapter for GpuiAdapter {}
12
13impl<B, C> CanAttach<B, C> for GpuiAdapter
14where
15    B: gpui::ParentElement,
16    C: gpui::IntoElement,
17{
18    #[inline]
19    fn do_attach(builder: B, child: C) -> B {
20        builder.child(child)
21    }
22}
23
24impl<B, I, C> CanAttachMany<B, I, C> for GpuiAdapter
25where
26    B: gpui::ParentElement,
27    I: IntoIterator<Item = C>,
28    C: gpui::IntoElement,
29{
30    #[inline]
31    fn do_attach_many(builder: B, children: I) -> B {
32        builder.children(children)
33    }
34}