Thank you for your help ! @Yandros I don't understand how your code is better than : playground
Could you explain me please ?
I don't find the macro really useful but i'm new to rust so you're explanation would be really nice !
It isn't really better. There are a lot of crates that provide various macros for all sorts of things, but if you're just doing it once or twice, it doesn't make much sense to hide it behind a macro.
The difference lies in that you can have multiple statements affected by a single #[cfg(...)]; my example illustrated that poorly with a block of a single expression, but it can be useful.
For the sake of having DRY code, having to write twice the target of the #[cfg(...)] (+ #[cfg(not(...))]) is suboptimal, hence a macro that let's you write else instead.
If you are new to Rust this is clearly not the most important, so you can skip this detail (especially given that macros use their own "language" / syntax), but later on, macros can be a great tool to avoid code repetition, leading to more maintainable code