bi() is not a valid item so you get a compilation error as expected. If you intended for it to be a call to the function bi then you'll have to put the bi() inside a function body.
Sorry I don't understand what you're saying. The example also doesn't look like the expected output but rather what you tried in your macro.
Anyway I'm gonna take a guess:
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn};
#[proc_macro_attribute]
pub fn get(_: TokenStream, input: TokenStream) -> TokenStream {
let func = parse_macro_input!(input as ItemFn);
let name = &func.sig.ident;
let body = &func.block;
let main = quote! {
fn #name() -> String {
fn billionaire() -> String #body
let billionaire = billionaire();
let value = format!("llama {}",billionaire);
value
}
};
TokenStream::from(main)
}
This wraps the code you wrote in a function with the same name as the one on which you apply the macro. So for example this code: