bon_macros/builder/
item_fn.rsuse super::builder_gen::input_fn::{FnInputCtx, FnInputCtxParams};
use super::builder_gen::{MacroOutput, TopLevelConfig};
use crate::normalization::SyntaxVariant;
use crate::util::prelude::*;
use syn::visit_mut::VisitMut;
pub(crate) fn generate(
config: TopLevelConfig,
orig_fn: syn::ItemFn,
namespace: &crate::normalization::GenericsNamespace,
) -> Result<TokenStream> {
let mut norm_fn = orig_fn.clone();
crate::normalization::NormalizeLifetimes::new(namespace).visit_item_fn_mut(&mut norm_fn);
crate::normalization::NormalizeImplTraits::new(namespace).visit_item_fn_mut(&mut norm_fn);
let fn_item = SyntaxVariant {
orig: orig_fn,
norm: norm_fn,
};
let ctx = FnInputCtx::new(FnInputCtxParams {
namespace,
fn_item,
impl_ctx: None,
config,
});
let adapted_fn = ctx.adapted_fn()?;
let MacroOutput {
start_fn,
other_items,
} = ctx.into_builder_gen_ctx()?.output()?;
Ok(quote! {
#adapted_fn
#start_fn
#other_items
})
}