#gpui #adapter #builder-pattern #dsl #builderx

builderx-gpui

gpui adapter implementations for the builderx DSL

1 unstable release

Uses new Rust 2024

0.1.0 Nov 30, 2025

#2713 in Rust patterns


Used in builderx

Apache-2.0

53KB
75 lines

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.


builderx

Builder-pattern UI DSL for Rust with pluggable adapters.

Crates

  • modules/builderx: facade re-exporting bx!, core traits, and optional adapters.
  • modules/builderx-core: adapter/attach traits and the default adapter.
  • modules/builderx-macros: proc-macro implementation of bx!.
  • modules/builderx-gpui: gpui adapter (enable via builderx feature gpui).

Usage

use builderx::{bx, AttachChild, AttachChildren};

#[derive(Default, Debug, PartialEq)]
struct Stub(Vec<&'static str>);

impl AttachChild<&'static str> for Stub {
    fn attach_child(mut self, child: &'static str) -> Self {
        self.0.push(child);
        self
    }
}

impl AttachChildren<&'static str> for Stub {
    fn attach_children<I>(mut self, children: I) -> Self
    where
        I: IntoIterator<Item = &'static str>,
    {
        self.0.extend(children);
        self
    }
}

let built = bx! { Stub::default() { "a", ..["b", "c"] } };
assert_eq!(built.0, ["a", "b", "c"]);

Docs

  • Generate workspace docs without dependencies: cargo doc --no-deps --workspace.
  • gpui adapter: cargo doc -p builderx --features gpui.

Dependencies

~44–88MB
~1.5M SLoC