//! gpui adapter implementations for builderx.
//!
//! Plug this adapter in (feature `gpui` on the `builderx` facade) to make the
//! `bx!` macro emit gpui-compatible builder chains.

use builderx_core::{BxAdapter, CanAttach, CanAttachMany};

/// Adapter type for gpui builders.
pub struct GpuiAdapter;

impl BxAdapter for GpuiAdapter {}

impl<B, C> CanAttach<B, C> for GpuiAdapter
where
    B: gpui::ParentElement,
    C: gpui::IntoElement,
{
    #[inline]
    fn do_attach(builder: B, child: C) -> B {
        builder.child(child)
    }
}

impl<B, I, C> CanAttachMany<B, I, C> for GpuiAdapter
where
    B: gpui::ParentElement,
    I: IntoIterator<Item = C>,
    C: gpui::IntoElement,
{
    #[inline]
    fn do_attach_many(builder: B, children: I) -> B {
        builder.children(children)
    }
}
