#ifndef NDEBUG ... is used in C because it means that if there is a typo in the macro name or somebody forgot about it, the section is turned on (which usually means assertions enabled). The first reason doesnāt apply to Rust code because the compiler will tell you if the macro names are wrong.
Optimisation levels: are there only two (on/off)? GCC supports many (extracts from man page):
With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.
-O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code.
-O3 Optimize yet more.
-O0 Reduce compilation time and make debugging produce the expected results. This is the default.
-Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
As noted here, disabling optimisations can be useful to reduce compilation time and to make code behave in a more expected manner when run in a debugger. This implies that under specific circumstances disabling optimisations is useful, but not that this needs to be the default.
From my point of view, an optimisation level equivalent to -O1 or -O2 would be a good default. (Not -O3 because some of those optimisations result in numeric approximations or in some cases, significantly larger code size and maybe other draw-backs.)