u/Botahamec

▲ 15 r/rust

Feluments - convenience macro for Rust builders

https://lib.rs/crates/feluments

Hello! I recently had a use-case for optional arguments for structs in Rust. This is often solved using builders, but I wanted something that looks more like conventional Rust syntax. So I learned some derive macros and came up with my own solution.

Feluments has the Builder derive macro that many other libraries support. But it also has a build! macro, which uses the conventional Rust syntax.

build!(Foo { x: 32, y: "bar" }) == Foo::builder().x(32).y("bar")

The build! macro is also compatible with other builder crates, such as bon. But the Builder derive macro implemented in feluments is designed with the build! macro in mind.

u/Botahamec — 2 months ago