apdopa6 0 #1 Опубликовано 1 час назад Today I tried applying macros in a more practical way by replacing repeated sections of code in a small Rust project I was working on. At first, I didn’t expect much difference, but the result actually surprised me. The code became shorter and easier to manage almost immediately. Instead of writing similar logic multiple times, I defined it once in a macro and reused it across different parts of the project. This made the structure cleaner and reduced clutter. However, I also realized that it’s easy to go too far with macros. If I replace everything with macros, the code becomes harder to understand later. So I started thinking more carefully about where macros actually make sense. I learned that they are best used when repetition is clear and patterns are obvious. For unique logic, normal functions still feel better. This balance between macros and functions is something I’m still figuring out. But overall, I can see how macros can significantly improve code organization when used correctly. 0 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты