Avatar ·

How to use macros between module files in Rust?

Hi everyone! I'm new to Rust and ran into a problem when trying to use macros across different files in my project. I have a library with a modular structure, and I want to define a macro in one module file and then use it in another.\n\nHere's the simplified structure of my project:\n\n```\nsrc/\n├── main.rs\n├── macros.rs\n└── utils/\n └── mod.rs\n```\n\nIn the `macros.rs` file, I declared a simple macro:\n\n```rust\nmacro_rules! say_hello {\n () => {\n println!("Hello from macro!");\n };\n}\n```\n\nThen in `main.rs`, I include the modules like this:\n\n```rust\nmod macros;\nmod utils;\n\nfn main() {\n say_hello!(); // Works!\n utils::do_something();\n}\n```\n\nAnd in `utils/mod.rs`, I'm trying to call the same macro:\n\n```rust\npub fn do_something() {\n say_hello!(); // O