systemprompt_models/macros.rs
1/// Generates builder-style `with_*` methods for Option fields.
2///
3/// Each method takes `self` by value and returns `Self`, setting the field to
4/// `Some(value)`.
5///
6/// # Usage
7/// ```rust
8/// impl MyStruct {
9/// builder_methods! {
10/// with_name(name) -> String,
11/// with_status(status) -> String,
12/// with_limit(limit) -> i64,
13/// }
14/// }
15/// ```
16#[macro_export]
17macro_rules! builder_methods {
18 ($( $method:ident ( $field:ident ) -> $ty:ty ),* $(,)?) => {
19 $(
20 pub fn $method(mut self, $field: $ty) -> Self {
21 self.$field = Some($field);
22 self
23 }
24 )*
25 };
26}