1use crate::parsing::{ItemSigConfig, ItemSigConfigParsing, SpannedKey};
2use crate::util::prelude::*;
3use darling::FromMeta;
45const DOCS_CONTEXT: &str = "builder struct's impl block";
67fn parse_setter_fn(meta: &syn::Meta) -> Result<SpannedKey<ItemSigConfig>> {
8let params = ItemSigConfigParsing {
9 meta,
10 reject_self_mentions: Some(DOCS_CONTEXT),
11 }
12 .parse()?;
1314 SpannedKey::new(meta.path(), params)
15}
1617fn parse_docs(meta: &syn::Meta) -> Result<SpannedKey<Vec<syn::Attribute>>> {
18crate::parsing::parse_docs_without_self_mentions(DOCS_CONTEXT, meta)
19}
2021#[derive(Debug, FromMeta)]
22pub(crate) struct SettersConfig {
23pub(crate) name: Option<SpannedKey<syn::Ident>>,
24pub(crate) vis: Option<SpannedKey<syn::Visibility>>,
2526#[darling(rename = "doc", default, with = parse_docs, map = Some)]
27pub(crate) docs: Option<SpannedKey<Vec<syn::Attribute>>>,
2829#[darling(flatten)]
30pub(crate) fns: SettersFnsConfig,
31}
3233#[derive(Debug, FromMeta)]
34pub(crate) struct SettersFnsConfig {
35/// Config for the setter that accepts the value of type T for a member of
36 /// type `Option<T>` or with `#[builder(default)]`.
37 ///
38 /// By default, it's named `{member}` without any prefix or suffix.
39#[darling(default, with = parse_setter_fn, map = Some)]
40pub(crate) some_fn: Option<SpannedKey<ItemSigConfig>>,
4142/// The setter that accepts the value of type `Option<T>` for a member of
43 /// type `Option<T>` or with `#[builder(default)]`.
44 ///
45 /// By default, it's named `maybe_{member}`.
46#[darling(default, with = parse_setter_fn, map = Some)]
47pub(crate) option_fn: Option<SpannedKey<ItemSigConfig>>,
48}