Skip to main content

systemprompt_models/
macros.rs

1//! Declarative macros shared across the crate's builder types.
2//!
3//! `builder_methods!` generates fluent setter methods that wrap each
4//! field value in `Some(..)`, for builders over structs whose fields
5//! are `Option<T>`.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10#[macro_export]
11macro_rules! builder_methods {
12    ($( $method:ident ( $field:ident ) -> $ty:ty ),* $(,)?) => {
13        $(
14            pub fn $method(mut self, $field: $ty) -> Self {
15                self.$field = Some($field);
16                self
17            }
18        )*
19    };
20}