MCPcopy Index your code
hub / github.com/estebank/makeit

github.com/estebank/makeit @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
17 symbols 21 edges 5 files 1 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Compile-time checked Builder pattern derive macro with zero-memory overhead

This is very much a work-in-progress. PRs to bring this to production quality are welcome.

The Builder Pattern is a design pattern to allow the construction of complex types one field at a time by calling methods on a builder type. This crate provides a derive macro that allows you to annotate any struct to create a type-level state machine that requires all mandatory fields to be set once and only at compile-time (otherwise you won't be able to call .build() on it).

use makeit::{Buildable, Builder};

#[derive(Builder)]
struct Foo<'a, T: std::fmt::Debug> {
    bar: &'a T,
    #[default(42)]
    baz: i32,
}

// This is the expected use
let x = Foo::builder().set_bar(&()).set_baz(42).build();
// The following builds because of the `default` annotation on `baz`
let x = Foo::builder().set_bar(&()).build();
// The following won't build because `bar` hasn't been set
let x = Foo::builder().set_baz(0).build();

You can look at the examples directory for a showcase of the available features.

The created Builder type has zero-memory overhead because it uses a MaybeUninit backed field of the type to be built.

Error messages

One of the main downsides of the typestate pattern are inscrutable error messages. However, the since this crate generates type-state parameters with readable names, rustc can produce readable error messages: Screenshot of rustc error messages, showing how the compiler tells you when you have an unset or double-set field

Extension points exported contracts — how you extend this code

Buildable (Interface)
NOTE: This type isn't really *needed*, but having a trait means that we're resilient to cases where the type being built
makeit/src/lib.rs

Core symbols most depended-on inside this repo

y
called by 1
makeit/examples/invalid2.rs
x
called by 1
makeit/examples/valid.rs
y
called by 1
makeit/examples/valid.rs
x
called by 1
makeit/examples/invalid1.rs
main
called by 0
makeit/examples/invalid2.rs
z
called by 0
makeit/examples/valid.rs
main
called by 0
makeit/examples/valid.rs
main
called by 0
makeit/examples/invalid1.rs

Shape

Function 10
Class 6
Interface 1

Languages

Rust100%

Modules by API surface

makeit/examples/valid.rs7 symbols
makeit/examples/invalid1.rs4 symbols
makeit/examples/invalid2.rs3 symbols
makeit-derive/src/lib.rs2 symbols
makeit/src/lib.rs1 symbols

For agents

$ claude mcp add makeit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact