Macros placement strategy inside crate

I have some macro's to make my life easier inside my program.
What is the best strategy: centralize them in 1 macro file? Or put them inside the file where the structs or data reside on which macro's are operating ("close to source")?

I usually put the macro it in the module that is the lowest common denominator module of everywhere it is used. Say I use the macro in crate::foo and crate::foo::bar, but not in crate or in crate::baz, I'd put it in crate::foo. If I were to use it in crate::foo and crate::baz, I'd put it somewhere in crate. In both cases, possibly inside an util or macro sub-module, so in the former case in crate::foo::util and the latter in crate::util.

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.