List all functions of a module or file (with Macros)? [SOLVED]

Hello dear community,

I need your help, is it possible to list all the functions contained in a module or a file ?, with Macro of course.

Thanks a lot for your time.

You can use cargo doc to see which functions are in a particular module if you just want to see what you can do with it.

However, it's not possible to list the functions at runtime without wiring it up yourself. Rust doesn't use a runtime that tracks all functions and types that lets a program inspect itself while running ("reflection").

If it's the latter, can you share a bit more about what you are trying to achieve? There's a very good chance what you want to do is possible, but would be solved differently to how Python or Java might do things.


thank you for your answer, I want to list the functions during the build phase (I specified the word Macro :laughing:), I found how to do it,

here is how to do it, if it can help someone :

pub fn my_macro(
    _attr: proc_macro::TokenStream,
    item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
    // println!("old item: \"{}\"", item);
      let input = parse_macro_input!(item as syn::ItemMod);

      let elems = &input.content.iter().next().unwrap().1;

       for aa in elems.iter() {
           match aa {
               syn::Item::Fn(f) => {
                   if f.attrs.len() > 0 {
                       println!("-**********\n\n iter : {:?} \n", f.attrs[0]);

               _ => {}

     let code = quote!(   


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.